(navigation image)
Home American Libraries | Canadian Libraries | Universal Library | Community Texts | Project Gutenberg | Children's Library | Biodiversity Heritage Library | Additional Collections
Search: Advanced Search
Anonymous User (login or join us)
Upload
See other formats

Full text of "Php Tutorials"

PHP Manual 

Stig Saether Bakken 
Alexander Aulbach 
Egon Schmid 
Jim Winstead 
Lars Torben Wilson 
Rasmus Lerdorf 
Zeev Suraski 

Edited by 

Stig Saether Bakken 

Copyright © 1997, 1998, 1999 by the PHP Documentation Group 

Additionally edited to reflect changes introduced 

with PHP Lite Edition, 

by Axis Communications AB 

(August 2002) 



Dedication 

Date: 

Table of Contents 

Preface 

About this Manual 
L Getting Started 

1. Introduction 

2. Installation 

3. Configuration 

4. Security 

II. Language Reference 

5. Basic syntax 

6. Types 

7. Variables 

8. Constants 

9. Expressions 



10. operators 

11. Control Structures 

12. Functions 

13. Classes and Objects 

III. Features 

14. Error handling 

15. Creating GIF images 

16. HTTP authentication with PHP 

17. Cookies 

18. Handling file uploads 

19. Using remote files 

20. Connection handling 

21. Persistent database connections 

IV. Function Reference 

I. // Adabas D functions 

II. // Apache-specific functions 

III. // Arbitrary precision mathematics functions 

IV. Array functions 

V. // Aspell functions 

VI. // Calendar functions 

VII. // ClibPDF functions 

VIII. // Compression functions 

IX. // Database (dbm-style) abstraction layer functions 

X. Date and Time functions 

XI. // dBase functions 

XII. // dbm functions 

XIII. Directory functions 

XIV. // Dynamic Loading functions 

XV. // Encryption functions 

XVI. // filePro functions 

XVII. Filesystem functions 

XVIII. // Forms Data Format functions 

XIX. FTP functions 

XX. // Hash functions 



XXI. HTTP functions 

XXII. // Hyperwave functions 

XXIII. // Image functions 

XXIV. // IMAP functions 

XXV. // Informix functions 

XXVI. // InterBase functions 

XXVII. // LDAP functions 

XXVIII. // Mail functions 

XXIX. // Matliematical functions 

XXX. // MCAL functions 

XXXI. // Microsoft SQL Server functions 

XXXII. Miscellaneous functions 

XXXIII. // mSQL functions 

XXXIV. // MySQL functions 

XXXV. Network functions 

XXXVI. // NIS functions 

XXXVII. // ODBC functions 

XXXVIII. // Oracle functions 

XXXIX. // Oracle 8 functions 
XL. // PDF functions 

XLI. // Perl-compatible Regular Expression functions 

XLII. PHP options & information 

XLIII. // POSIX functions 

XLIV. // PostgreSQL functions 

XLV. Program Execution functions 

XLVI. // GNU Recode functions 

XL VII. // Regular expression functions 

XL VIII. // Semaphore and shared memory functions 

XLIX. // Session handling functions 

L. // SNMP functions 

LI. // Solid functions 

LII. String functions 

LIII. // Sybase functions 

LIV. URL functions 



LV. Variable functions 
LVI. // Vmailmgr functions 
LVII. // WDDX functions 
LVIII. // XML parser functions 
V. Appendixes 

A. Migrating from PHP/FI 2.0 to PHP 3.0 

B. PHP development 

C. The PHP Debugger 



Next 
Preface 



PHP Manual 



Copyright 

This manual is © Copyright 1997, 1998, 1999 the PHP Documentation Group. The members of this 
group are listed on the front page of this manual . 

This manual can be redistributed under the terms of the GNU General Public License as published 
by the Free Software Foundation; either version 2 of the License, or (at your option) any later 
version. 

Home 



PHP Manual 

Prev Next 



Preface 

Table of Contents 

About this Manual 

PHP, which stands for "PHP: Hypertext Preprocessor", is an HTML-embedded 
scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple 
of unique PHP-specific features thrown in. The goal of the language is to allow web 
developers to write dynamically generated pages quickly. 



About this Manual 



This manual is written in SGML using the DocBook DTD , using DSSSL (Document Style and 
Semantics Specification Language) for formatting. The tools used for formatting HTML, TeX and 
RTF versions are Jade , written by James Clark and The Modular DocBook Stylesheets written by 
Norman Walsh . PHP's documentation framework was assembled by Stig S aether Bakken . 

Prev Home Next 

PHP Manual Getting Started 



PHP Manual 

Prev Next 



I. Getting Started 



Table of Contents 

1. Introduction 

2. Installation 

3. Configuration 

4. Security 



Prev Home Next 

Preface Introduction 



PHP Manual 

Prev Next 



Chapter 1 . Introduction 



Table of Contents 

What is PHP? 
What can PHP do? 
A brief history of PHP 

What is PHP? 

PHP (officially "PHP: Hypertext Preprocessor") is a server-side HTML-embedded scripting 
language. 

Simple answer, but what does that mean? An example: 

Example 1-1. An introductory example 

<html> 

<head> 

<title>Example</title> 
</head> 
<body> 

<?php echo "Hi, I'm a PHP script!"; ?> 
</body> 
</html> 

Notice how this is different from a CGI script written in other languages like Perl or C ~ instead of 
writing a program with lots of commands to output HTML, you write an HTML script with a some 
embedded code to do something (in this case, output some text). The PHP code is enclosed in 
special start and end tags that allow you to jump into and out of PHP mode. 

What distinguishes PHP from something like client-side Javascript is that the code is executed on 
the server. If you were to have a script similar to the above on your server, the client would receive 
the results of running that script, with no way of determining what the underlying code may be. 
You can even configure your web server to process all your HTML files with PHP, and then there's 
really no way that users can tell what you have up your sleeve. 

Prev Home Next 

Getting Started Up What can PHP do? 



PHP Manual 

Prev Next 



Chapter 2. Installation 

Table of Contents 

Downloading the latest version 
Installation on UNIX systems 
Installation on Windows 95/98/NT systems 
Problems? 

Downloading the latest version 

The source code, and binary distributions for some platforms (including Windows), can be found at 

http : //www.php .net/ . 

Prev Home Next 

A brief history of PHP Ug Installation on UNIX systems 



PHP Manual 

Prev Next 



Chapter 3. Configuration 

Table of Contents 

The configuration file 



The configuration file 



The configuration file (called php3 . ini in PHP 3.0, and simply php . ini as of PHP 4.0) is read 
when PHP starts up. For the server module versions of PHP, this happens only once when the web 
server is started. For the CGI version, it happens on every invocation. 

When using PHP as an Apache module, you can also change the configuration settings using 
directives in Apache configuration files and .htaccess files. 

With PHP 3.0, there are Apache directives that correspond to each configuration setting in the 
php 3 .ini name, except the name is prefixed by "php3_". 

With PHP 4.0, there are just a few Apache directives that allow you to change the PHP 
configuration settings. 

php_value name value 

This sets the value of the specified variable. 
php_flag name on I of f 

This is used to set a Boolean configuration option. 
php_admin_value name value 

This sets the value of the specified variable. "Admin" configuration settings can only be set 
from within the main Apache configuration files, and not from .htaccess files. 

php_admin_flag name on I of f 

This is used to set a Boolean configuration option. 

You can view the settings of the configuration values in the output of phpinfoQ . You can also 
access the values of individial configuration settings using get_cfg_var() . 

General Configuration Directives 

asp_tags boolean 

Enables the use of ASP-like <% %> tags in addition to the usual <?php ?> tags. This 
includes the variable-value printing shorthand of <%- $value %>. For more information, see 



Escaping from HTML . 

Note: Support for ASP-style tags was added in 3.0.4. 

auto_ appen d_file string 

Specifies the name of a file that is automatically parsed after the main file. The file is 
included as if it was called with the includeQ function, so include_path is used. 

The special value none disables auto-appending. 

Note: If the script is terminated with exitQ , auto-append will not occur. 

auto_prepend_file string 

Specifies the name of a file that is automatically parsed before the main file. The file is 
included as if it was called with the includeQ function, so include_path is used. 

The special value none disables auto-prepending. 
cgi_ext string 
display_errors boolean 

This determines whether errors should be printed to the screen as part of the HTML output or 
not. 

doc_root string 

PHP's "root directory" on the server. Only used if non-empty. If PHP is configured with safe 
mode, no files outside this directory are served. 

engine boolean 

This directive is really only useful in the Apache module version of PHP. It is used by sites 
that would like to turn PHP parsing on and off on a per-directory or per- virtual server basis. 
By putting php3_engine off in the appropriate places in the httpd . conf file, PHP 
can be enabled or disabled. 

error_log string 

Name of file where script errors should be logged. If the special value sy slog is used, the 
errors are sent to the system logger instead. On UNIX, this means syslog(3) and on Windows 
NT it means the event log. The system logger is not supported on Windows 95. 

error_repor ting integer 

Set the error reporting level. The parameter is an integer representing a bit field. Add the 
values of the error reporting levels you want. 

Table 3-1. Error Reporting Levels 



bit value 


enabled reporting 


1 


normal errors 


2 


normal warnings 


4 


parser errors 


8 


non-critical style-related warnings 



The default value for this directive is 7 (normal errors, normal warnings and parser errors are 
shown). 

open_basedir string 

Limit the files that can be opened by PHP to the specified directory-tree. 

When a script tries to open a file with, for example, fopen or gzopen, the location of the file 
is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. 
All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. 

The special value . indicates that the directory in which the script is stored will be used as 
base-directory. 

Under Windows, separate the directories with a semicolon. On all other systems, separate the 
directories with a colon. As an Apache module, open_basedir paths from parent directories 
are now automatically inherited. 

Note: Support for multiple directories was added in 3.0.7. 

The default is to allow all files to be opened. 
gpc_order string 

Set the order of GET/POST/COOKIE variable parsing. The default setting of this directive is 
"GPC". Setting this to "GP", for example, will cause PHP to completely ignore cookies and 
to overwrite any GET method variables with POST-method variables of the same name. 

ignore_user_abort string 

On by default. If changed to Off scripts will be terminated as soon as they try to output 
something after a client has aborted their connection. ignore_user_abort() . 

lnclude_path string 

Specifies a list of directories where the requireQ , includeQ and fopen_with_path() 
functions look for files. The format is like the system's PATH environment variable: a list of 
directories separated with a colon in UNIX or semicolon in Windows. 

Example 3-1. UNIX include_path 

include_path= . : /home/httpd/php-lib 
Example 3-2. Windows include_path 

include_path=" . ; c : \www\phplib" 

The default value for this directive is . (only the current directory). 
isapi_ext string 
log_errors boolean 

Tells whether script error messages should be logged to the server's error log. This option is 
thus server-specific. 

magic_quotes_gpc boolean 

Sets the magic_quotes state for GPC (Get/Post/Cookie) operations. When magic_quotes are 
on, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a 



backslash automatically. If magic_quotes_sybase is also on, a single-quote is escaped with a 
single-quote instead of a backslash. 

magic_quotes_runtime boolean 

If magi c_quotes_runtime is enabled, most functions that return data from any sort of 
external source including databases and text files will have quotes escaped with a backslash. 
If magic_quotes_sybase is also on, a single-quote is escaped with a single-quote 
instead of a backslash. 

magic_quotes_sybase boolean 

If magic_quotes_sybase is also on, a single-quote is escaped with a single-quote 
instead of a backslash if magi c_quotes_gpc or magic_quotes_runtime is enabled. 

max_execut ion_t ime integer 

This sets the maximum time in seconds a script is allowed to take before it is terminated by 
the parser. This helps prevent poorly written scripts from tieing up the server. 

memory_limit integer 

This sets the maximum amount of memory in bytes that a script is allowed to allocate. This 
helps prevent poorly written scripts for eating up all available memory on a server. 

nsapi_ext string 

siiort_ope-n_tag boolean 

Tells whether the short form (<? ?>of PHP's open tag should be allowed. If you want to use 
PHP in combination with XML, you have to disable this option. If disabled, you must use the 
long form of the open tag (<?php ?>). 

sql . safe_mode boolean 

track_errors boolean 

If enabled, the last error message will always be present in the global variable 
$php_errormsg. 

track_vars boolean 

If enabled, GET, POST and cookie input can be found in the global associative arrays 
$HTTP_GET_VARS, $HTTP_POST_VARS and $HTTP_COOKIE_VARS, respectively. 

upload_tmp_dir string 

The temporary directory used for storing files when doing file upload. Must be writable by 
whatever user PHP is running as. 

user_dir string 

The base name of the directory used on a user's home directory for PHP files, for example 

public_html. 

warn_plus_overloadinghoo\e?in 

If enabled, this option makes PHP output a warning when the plus (+) operator is used on 
strings. This is to make it easier to find scripts that need to be rewritten to using the string 
concatenator instead ( . )• 



Mail Configuration Directives 

SMTP String 

DNS name or IP address of the SMTP server PHP under Windows should use for mail sent 
with the mailQ function. 

sendmail_from string 

Which "From:" mail address should be used in mail sent from PHP under Windows. 

sendmail_path string 

Where the sendmail program can be found, usually /usr/sbin/sendmail or 
/usr/lib/sendmail configure does an honest attempt of locating this one for you and 
set a default, but if it fails, you can set it here. 

Systems not using sendmail should set this directive to the sendmail wrapper/replacement 
their mail system offers, if any. For example, Qmail users can normally set it to 

/var/qmail /bin /sendmail. 

Safe Mode Configuration Directives 

safe_mode boolean 

Whether to enable PHP's safe mode. Read the Securitv chapter for more more information. 

safe_mode_exec_dir string 

If PHP is used in safe mode, systemQ and the other functions executing system programs 
refuse to start programs that are not in this directory. 

Debugger Configuration Directives 

debugger . host string 

DNS name or IP address of host used by the debugger. 

debugger . port string 

Port number used by the debugger. 
debugger . enai^led boolean 

Whether the debugger is enabled. 

Extension Loading Directives 

enable_dl boolean 

This directive is really only useful in the Apache module version of PHP. You can turn 



dynamic loading of PHP extensions with dlQ on and off per virtual server or per directory. 

The main reason for turning dynamic loading off is security. With dynamic loading, it's 
possible to ignore all the safe_mode and open_basedir restrictions. 

The default is to allow dynamic loading, except when using safe-mode. In safe-mode, it's 
always imposible to use dlQ . 

extension_dir string 

In what directory PHP should look for dynamically loadable extensions. 
extension string 

Which dynamically loadable extensions to load when PHP starts up. 

MySQL Configuration Directives 

mysql . all ow_per sis tent boolean 

Whether to allow persistent MySQL connections. 

mysql . default_host string 

The default server host to use when connecting to the database server if no other host is 
specified. 

mysql . default_user string 

The default user name to use when connecting to the database server if no other name is 
specified. 

mysql . default_pas sword string 

The default password to use when connecting to the database server if no other password is 
specified. 

mysql .max_per si stent integer 

The maximum number of persistent MySQL connections per process. 

mysql .max_links integer 

The maximum number of MySQL connections per process, including persistent connections. 

mSQL Configuration Directives 

msql . all ow_per sis tent boolean 

Whether to allow persistent mSQL connections. 

msql .max_per si stent integer 

The maximum number of persistent mSQL connections per process. 

msql .max_links integer 



The maximum number of mSQL connections per process, including persistent connections. 

Postgres Configuration Directives 

pgsql . allow_per si stent boolean 

Whether to allow persistent Postgres connections. 

pgsql .max_per si stent integer 

The maximum number of persistent Postgres connections per process. 

pgsql .max_links integer 

The maximum number of Postgres connections per process, including persistent connections. 

Sybase Configuration Directives 

Sybase . allow_per si stent boolean 

Whether to allow persistent Sybase connections. 

Sybase .max_persistent integer 

The maximum number of persistent Sybase connections per process. 

Sybase .max_links integer 

The maximum number of Sybase connections per process, including persistent connections. 

Sybase-CT Configuration Directives 

sybct . allow_persistent boolean 

Whether to allow persistent Sybase-CT connections. The default is on. 

sybct .max_per si stent integer 

The maximum number of persistent Sybase-CT connections per process. The default is -1 
meaning unlimited. 

sybct .max_links integer 

The maximum number of Sybase-CT connections per process, including persistent 
connections. The default is -1 meaning unlimited. 

sybct . min_server_sever it y integer 

Server messages with severity greater than or equal to sybct.min_server_severity will be 
reported as warnings. This value can also be set from a script by calling 
sybase_min_server_se verity (). The default is 10 which reports errors of information 
severity or greater. 

sybct . min_client_severity integer 

Client library messages with severity greater than or equal to sybct.min_client_severity will 



be reported as warnings. This value can also be set from a script by calling 
sybase_min_client_severity(). The default is 10 which effectively disables reporting. 

sybct . login_timeout integer 

The maximum time in seconds to wait for a connection attempt to succeed before returning 
failure. Note that if max_execution_time has been exceeded when a connection attempt times 
out, your script will be terminated before it can take action on failure. The default is one 
minute. 

sybct . timeout integer 

The maximum time in seconds to wait for a select_db or query operation to succeed before 
returning failure. Note that if max_execution_time has been exceeded when am operation 
times out, your script will be terminated before it can take action on failure. The default is no 
limit. 

sybct . hostname string 

The name of the host you claim to be connecting from, for display by sp_who. The default is 
none. 

Informix Configuration Directives 

ifx. allow_per si stent boolean 

Whether to allow persistent Informix connections. 

ifx .max_persistent integer 

The maximum number of persistent Informix connections per process. 

ifx .max_links integer 

The maximum number of Informix connections per process, including persistent connections. 

ifx. default_host string 

The default host to connect to when no host is specified in ifx_connect() or ifx_pconnect() . 

ifx . default_user string 

The default user id to use when none is specified in ifx_connect() or ifx_pconnect() . 

ifx . default_pas sword string 

The default password to use when none is specified in ifx_connect() or ifx_pconnect() . 

ifx. blob in file boolean 

Set to true if you want to return blob columns in a file, false if you want them in memory. 
You can override the setting at runtime with ifx_blobinfile_mode() . 

ifx. t ext as va rch a r boolean 

Set to true if you want to return TEXT columns as normal strings in select statements, false if 
you want to use blob id parameters. You can override the setting at runtime with 
ifx_textas varchar . 



ifx.byteasvarcharhoolesin 

Set to true if you want to return BYTE columns as normal strings in select queries, false if 
you want to use blob id parameters. You can override the setting at runtime with 
ifx_textas varchar . 

ifx. charas var char hooloan 

Set to true if you want to trim trailing spaces from CHAR columns when fetching them. 

1 fx . null format boolean 

Set to true if you want to return NULL columns as the literal string "NULL", false if you 
want them returned as the empty string "". You can override this setting at runtime with 
ifx_nullformat() . 

BC Math Configuration Directives 

bcmath .scale integer 

Number of decimal digits for all bcmath functions. 

Browser Capability Configuration Directives 

browscap string 

Name of browser capabilities file. See also get_browser() . 

Unified ODBC Configuration Directives 

uodbc . default_db string 

ODBC data source to use if none is specified in odbc_connect() or odbc_pconnect() . 

uodbc . default_user string 

User name to use if none is specified in odbc_connect() or odbc_pconnect() . 

uodbc. def au It _pw sivirvg 

Password to use if none is specified in odbc_connect() or odbc_pconnect() . 

uodbc . allow_perslstent boolean 

Whether to allow persistent ODBC connections. 

uodbc . max_persistent integer 

The maximum number of persistent ODBC connections per process. 

uodbc .max_l inks integer 

The maximum number of ODBC connections per process, including persistent connections. 



Prev Home Next 

Problems? U£ Security 



PHP Manual 

Prev Next 



Chapter 4. Security 



Table of Contents 

CGI binary 

Apache module 

PHP is a powerful language and the interpreter, whether included in a web server as a module or 
executed as a separate CGI binary, is able to access files, execute commands and open network 
connections on the server. These properties make anything run on a web server insecure by default. 
PHP is designed specifically to be a more secure language for writing CGI programs than Perl or C, 
and with correct selection of compile-time and runtime configuration options it gives you exactly 
the combination of freedom and security you need. 

As there are many different ways of utilizing PHP, there are many configuration options controlling 
its behaviour. A large selection of options guarantees you can use PHP for a lot of purposes, but it 
also means there are combinations of these options and server configurations that result in an 
insecure setup. This chapter explains the different configuration option combinations and the 
situations they can be safely used. 



CGI binary 

Possible attacks 



Using PHP as a CGI binary is an option for setups that for some reason do not wish to integrate 
PHP as a module into server software (like Apache), or will use PHP with different kinds of CGI 
wrappers to create safe chroot and setuid environments for scripts. This setup usually involves 
installing executable PHP binary to the web server cgi-bin directory. CERT advisory CA-96.11 
recommends against placing any interpreters into cgi-bin. Even if the PHP binary can be used as a 
standalone interpreter, PHP is designed to prevent the attacks this setup makes possible: 

q Accessing system files: http : //my . host/cgi-bin/php?/etc/passwd 

The query information in a url after the question mark (?) is passed as command line 
arguments to the interpreter by the CGI interface. Usually interpreters open and execute the 
file specified as the first argument on the command line. 

When invoked as a CGI binary, PHP refuses to interpret the command line arguments. 

q Accessing any web document on server: 

http : //my . host/cgi-bin/php/secret/doc . html 

The path information part of the url after the PHP binary name, / secret /doc . html is 



conventionally used to specify the name of the file to be opened and interpreted by the CGI 
program. Usually some web server configuration directives (Apache: Action) are used to 
redirect requests to documents like http : //my .host /secret /script .php3 to the 
PHP interpreter. With this setup, the web server first checks the access permissions to the 
directory /secret, and after that creates the redirected request 

http : //my . host/cgi-bin/php/secret/script .php3. Unfortunately, if the 
request is originally given in this form, no access checks are made by web server for file 
/secret/script .php3, but only for the /cgi-bin/php file. This way any user able 
to access /cgi-bin/php is able to access any protected document on the web server. 

In PHP, compile-time configuration option — enable-force-cgi-redirect and runtime 
configuration directives doc_root and user_dir can be used to prevent this attack, if the server 
document tree has any directories with access restrictions. See below for full the explanation 
of the different combinations. 

Case 1 : only public files served 

If your server does not have any content that is not restricted by password or ip based access 
control, there is no need for these configuration options. If your web server does not allow you to 
do redirects, or the server does not have a way to communicate to the PHP binary that the request is 
a safely redirected request, you can specify the option — disable-force-cgi-redirect to the configure 
script. You still have to make sure your PHP scripts do not rely on one or another way of calling the 
script, neither by directly http : //my . host /cgi-bin/php/dir/ script .php3 nor by 
redirection http : //my . host /dir/ script .php3. 

Redirection can be configured in Apache by using AddHandler and Action directives (see below). 

Case 2: using -enable-force-cgi-redirect 

This compile-time option prevents anyone from calling PHP directly with a url like 

http : //my . host/cgi-bin/php/secretdir/script .php3. Instead, PHP will only 
parse in this mode if it has gone through a web server redirect rule. 

Usually the redirection in the Apache configuration is done with the following directives: 

Action php3-script /cgi-bin/php 
AddHandler php3-script .php3 

This option has only been tested with the Apache web server, and relies on Apache to set the 
non-standard CGI environment variable REDIRECT_STATUS on redirected requests. If your web 
server does not support any way of telling if the request is direct or redirected, you cannot use this 
option and you must use one of the other ways of running the CGI version documented here. 

Case 3: setting doc_root or user_dir 

To include active content, like scripts and executables, in the web server document directories is 
sometimes consider an insecure practice. If, because of some configuration mistake, the scripts are 



not executed but displayed as regular HTML documents, this may result in leakage of intellectual 
property or security information like passwords. Therefore many sysadmins will prefer setting up 
another directory structure for scripts that are accessible only through the PHP CGI, and therefore 
always interpreted and not displayed as such. 

Also if the method for making sure the requests are not redirected, as described in the previous 
section, is not available, it is necessary to set up a script doc_root that is different from web 
document root. 

You can set the PHP script document root by the configuration directive doc_root in the 
configuration file , or you can set the environment variable PHP_DOCUMENT_ROOT. If it is set, the 
CGI version of PHP will always construct the file name to open with this doc_root and the path 
information in the request, so you can be sure no script is executed outside this directory (except for 

user_dir below). 

Another option usable here is user_dir . When user_dir is unset, only thing controlling the opened 

file name is doc_root. Opening anurl like http : //my .host /-user /doc .php3 does not 
result in opening a file under users home directory, but a file called -user/ doc. php3 under 
doc_root (yes, a directory name starting with a tilde [-]). 

If user_dir is set to for example public_php, a request like 

http : //my . host/~user/doc .php3 will open a file called doc .php3 under the directory 

named public_php under the home directory of the user. If the home of the user is 

/home/user, the file executed is /home/user /public_php/doc . php3. 

user_dir expansion happens regardless of the doc_root setting, so you can control the 
document root and user directory access separately. 

Case 4: PHP parser outside of web tree 

A very secure option is to put the PHP parser binary somewhere outside of the web tree of files. In 
/usr/local/bin, for example. The only real downside to this option is that you will now have 
to put a line similar to: 

# ! /usr/local/bin/php 

as the first line of any file containing PHP tags. You will also need to make the file executable. 
That is, treat it exactly as you would treat any other CGI script written in Perl or sh or any other 
common scripting language which uses the # ! shell-escape mechanism for launching itself. 

To get PHP to handle PATH_INFO and PATH_TRANSLATED information correctly with this 
setup, the php parser should be compiled with the — enable-discard-path configure option. 

Prev Home Next 

Configuration Ug Apache module 



PHP Manual 

Prev Chapter 1. Introduction Next 



What can PHP do? 



At the most basic level, PHP can do anything any other CGI program can do, such as collect form 
data, generate dynamic page content, or send and receive cookies. 

Perhaps the strongest and most significant feature in PHP is its support for a wide range of 
databases. Writing a database-enabled web page is incredibly simple. The following databases are 
currently supported: 

Adabas D InterBase Solid 
dBase mSQL Sybase 

Empress MySQL Velocis 
FilePro Oracle Unix dbm 

Informix PostgreSQL 

PHP also has support for talking to other services using protocols such as IMAP, SNMP, NNTP, 
POPS, or even HTTP. You can also open raw network sockets and interact using other protocols. 

Prev Home Next 

Introduction Ug A brief history of PHP 



PHP Manual 

Prev Chapter 1. Introduction Next 



A brief history of PHP 



PHP was conceived sometime in the fall of 1994 by Rasmus Lerdorf . Early non-released versions 
were used on his home page to keep track of who was looking at his online resume. The first 
version used by others was available sometime in early 1995 and was known as the Personal Home 
Page Tools. It consisted of a very simplistic parser engine that only understood a few special 
macros and a number of utilities that were in common use on home pages back then. A guestbook, 
a counter and some other stuff. The parser was rewritten in mid- 1995 and named PHP/FI Version 2. 
The FI came from another package Rasmus had written which interpreted html form data. He 
combined the Personal Home Page tools scripts with the Form Interpreter and added mSQL support 
and PHP/FI was born. PHP/FI grew at an amazing pace and people started contributing code to it. 

It is difficult to give any hard statistics, but it is estimated that by late 1996 PHP/FI was in use on at 
least 15,000 web sites around the world. By mid-1997 this number had grown to over 50,000. 
Mid- 1997 also saw a change in the development of PHP. It changed from being Rasmus' own pet 
project that a handful of people had contributed to, to being a much more organized team effort. 
The parser was rewritten from scratch by Zeev Suraski and Andi Gutmans and this new parser 
formed the basis for PHP Version 3. A lot of the utility code from PHP/FI was ported over to PHP3 
and a lot of it was completely rewritten. 

Today (mid- 1999) either PHP/FI or PHP3 ships with a number of commercial products such as C2's 
StrongHold web server and RedHat Linux. A conservative estimate based on an extrapolation from 
numbers provided by NetCraft would be that PHP is in use on over 150,000 sites around the world. 
To put that in perspective, that is more sites than run Netscape's flagship Enterprise server on the 
Internet. 

Also as of this writing, work is underway on the next generation of PHP, which will utilize the 
powerful Zend scripting engine to deliver higher performance, and will also support running under 
webservers other than Apache as a native server module. 

Prev Home Next 

What can PHP do? Up Installation 



PHP Manual 

Prev Next 



Chapter 5. Basic syntax 

Table of Contents 

Escaping from HTML 
Instruction separation 
Comments 



Escaping from HTML 



There are four ways of escaping from HTML and entering "PHP code mode": 
Example 5-1. Ways of escaping from HTML 

1. <? echo ("this is the simplest, an SGML processing instruction\n" ) ; ?> 

2. <?php echo ("if you want to serve XML documents, do like this\n"); ?> 

3. <script language="php"> 

echo ("some editors (like FrontPage) don't 
like processing instructions"); 
</script> 

4. <% echo ("You may optionally use ASP-style tags"); %> 
<%= $variable; # This is a shortcut for "<%echo .." %> 

The first way is only available if short tags have been enabled. This can be done via the short_tags() function, 
by enabling the short_open_tag configuration setting in the PHP config file, or by compiling PHP with the 
— enable-short-tags option to configure. 

The fourth way is only available if ASP-style tags have been enabled using the asp_tags configuration setting. 

Note: Support for ASP-style tags was added in 3.0.4. 

The closing tag for the block will include the immediately trailing newline if one is present. 

Prev Home Next 

Language Reference IPp Instruction separation 



PHP Manual 

Prev Next 



II. Language Reference 



Table of Contents 

5. Basic syntax 

6. Types 

7. Variables 

8. Constants 

9. Expressions 

10. Operators 

11. Control Structures 

12. Functions 

13. Classes and Objects 



Prev Home Next 

Apache module Basic syntax 



PHP Manual 

Prev Chapter 5. Basic syntax Next 



Instruction separation 



Instructions are separated the same as in C or perl - terminate each statement with a semicolon. 

The closing tag (?>) also implies the end of the statement, so the following are equivalent: 

<?php 

echo "This is a test"; 
?> 

<?php echo "This is a test" ?> 

Prev Home Next 

Basic syntax IJ£ Comments 



Prev 



PHP Manual 

Chapter 5. Basic syntax 



Next 



Comments 



PHP supports 'C, 'C++' and Unix shell-style comments. For example: 

<?php 

echo "This is a test"; // This is a one-line C++ style comment 

/* This is a multi line comment 
yet another line of comment */ 

echo "This is yet another test"; 

echo "One Final Test"; # This is shell-style style comment 
?> 



The "one-line" comment styles actually only comment to the end of the line or the current block of 
PHP code, whichever comes first. 

<hl>This is an <?# echo "simple"; ?> example . </hl> 
<p>The header above will say 'This is an example' . 

You should be careful not to nest 'C style comments, which can happen when commenting out 
large blocks. 

<?php 

echo "This is a test"; /* This comment will cause a problem */ 
V 
?> 



Prev 

Instruction separation 



Home 
UE 



Next 
Types 



PHP Manual 

Prev Chapter 2. Installation Next 

Installation on UNIX systems 

This section will guide you through the configuration and installation of PHP. Prerequisite knowledge and software: 
q Basic UNIX skills (being able to operate "make" and a C compiler) 
q An ANSI C compiler 
q A web server 

Quick Installation Instructions (Apache Module Version) 



1 



gunzip apache_l . 3 . x . tar . gz 



2. tar xvf apache_l . 3 . x . tar 

3. gunzip php-3 . . x . tar . gz 

4. tar xvf php-3 . . x .tar 

5. cd apache_1.3.x 

6. ./configure — prefix=/www 

7. cd ../php-3. 0.x 

8. ./configure --with-mysql --with-apache= . . /apache_l . 3 . x --enable-track-vars 

9 . make 

10. make install 

11. cd . . /apache_l . 3 . X 

12. ./configure --pref ix=/www --activate-module=src/modules/php3/libphp3 . a 

13. make 

14. make install 

Instead of this step you may prefer to simply copy the httpd binary 
overtop of your existing binary. Make sure you shut down your 
server first though. 

15. cd ../php-3. 0.x 

16. cp php3 . ini-dist /usr/local/lib/php3 . ini 

You can edit /usr/local/lib/php3 . ini file to set PHP options. If 
you prefer this file in another location, use 
--with-conf ig-f ile-path=/path in step 8. 

17. Edit your httpd. conf or srm.conf file and add: 

AddType application/x-httpd-php3 .php3 

You can choose any extension you wish here. .php3 is simply the one 
we suggest. 

18. Use your normal procedure for starting the Apache server. (You must 
stop and restart the server, not just cause the server to reload by 
use a HUP or USRl signal.) 



Configuration 

There are two ways of configuring PHP. 

q Using the "setup" script that comes with PHP. This script asks you a series of questions (almost like the 
"install" script of PHP/FI 2.0) and runs "configure" in the end. To run this script, type ./setup. 

This script will also create a file called "do-conf", this file will contain the options passed to configure. You 
can edit this file to change just a few options without having to re-run setup. Then type ./do-conf to run 
configure with the new options. 

q Running configure by hand. To see what options you have, type ./configure —help. 

Details about some of the different configuration options are listed below. 



Apache module 



To build PHP as an Apache module, answer "yes" to "Build as an Apache module?" (the --with-apache =.DJ.R 
option to configure) and specify the Apache distribution base directory. If you have unpacked your Apache 
distribution in /usr/local/www/apache_l .2.4, this is your Apache distribution base directory. The default 
directory is /usr/local/etc/httpd. 



fhttpd module 



To build PHP as an fhttpd module, answer "yes" to "Build as an fhttpd module?" (the --with-fhttpd =.DJ.R 
option to configure) and specify the fhttpd source base directory. The default directory is 

/usr/local/src/f httpd. If you are running fhttpd, building PHP as a module will give better performance, 
more control and remote execution capability. 

CGI version 

The default is to build PHP as a CGI program. If you are running a web server PHP has module support for, you 
should generally go for that solution for performance reasons. However, the CGI version enables Apache users to 
run different PHP-enabled pages under different user-ids. Please make sure you read through the Security chapter if 
you are going to run PHP as a CGI. 

Database Support Options 

PHP has native support for a number of databases (as well as ODBC): 

Adabas D 

--with-adabas=DJiR 

Compiles with Adabas D support. The parameter is the Adabas D install directory and defaults to 

/usr/ local /adabasd. 

Adabas home page 

dBase 

--with-dbase 



Enables the bundled DBase support. No external libraries are required. 

filePro 

--with-f ilepro 
Enables the bundled read-only filePro support. No external libraries are required. 

mSQL 

--with-msql=DJiR 

Enables mSQL support. The parameter to this option is the mSQL install directory and defaults to 
/usr/local/Hughes. This is the default directory of the mSQL 2.0 distribution, configure automatically 
detects which mSQL version you are running and PHP supports both 1 .0 and 2.0, but if you compile PHP with 
mSQL 1.0, you can only access mSQL 1.0 databases, and vice-versa. 

See also mSQL Configuration Directives in the configuration file . 
mSQL home page 

MySQL 

--with-inysql=DJi^ 

Enables MySQL support. The parameter to this option is the MySQL install directory and defaults to 
/usr/local. This is the default installation directory of the MySQL distribution. 

See also MySQL Configuration Directives in the configuration file . 
MySQL home page 

iODBC 

— with-iodbc=DTiR 

Includes iODBC support. This feature was first developed for iODBC Driver Manager, a freely redistributable 
ODBC driver manager which runs under many flavors of UNIX. The parameter to this option is the iODBC 
installation directory and defaults to /usr/local. 

FreeODBC home page or iODBC home page 

OpenLink ODBC 

--with-openlink=DJiR 

Includes OpenLink ODBC support. The parameter to this option is the OpenLink ODBC installation directory and 
defaults to /usr/local/openlink. 

OpenLink Software's home page 



Oracle 

--with-o racle=D li^ 

Includes Oracle support. Has been tested and should be working at least with Oracle versions 7.0 through 7.3. The 
parameter is the ORACLE_HOME directory. You do not have to specify this parameter if your Oracle environment 
has been set up. 

Oracle home page 

PostgreSQL 

--with-pgsql=L>Ji^ 

Includes PostgreSQL support. The parameter is the PostgreSQL base install directory and defaults to 

/usr/local/pgsql. 

See also Postgres Configuration Directives in the configuration file . 
PostgreSQL home page 

Solid 

— with-sol 1(1=1) liR 

Includes Solid support. The parameter is the Solid install directory and defaults to /usr/local/solld. 
Solid home page 

Sybase 

--wlth-sybase=DJi^ 

Includes Sybase support. The parameter is the Sybase install directory and defaults to /home/sybase. 
See also Sybase Configuration Directives in the configuration file . 
Sybase home page 

Sybase-CT 

--with- sybase-ct=D li? 

Includes Sybase-CT support. The parameter is the Sybase-CT install directory and defaults to /home/sybase. 
See also Sybase-CT Configuration Directives in the configuration file . 

Velocis 

--wlth-velocls=DJiR 

Includes Velocis support. The parameter is the Velocis install directory and defaults to /usr/local/velocls. 
Velocis home page 



A custom ODBC library 

--with-cust om-odbc=D li^ 

Includes support for an arbitrary custom ODBC library. The parameter is the base directory and defaults to 

/usr/local. 

This option implies that you have defined CUSTOM_ODBC_LIBS when you run the configure script. You also 
must have a valid odbc.h header somewhere in your include path. If you don't have one, create it and include your 
specific header from there. Your header may also require some extra definitions, particularly when it is 
multiplatform. Define them in CFLAGS. 

For example, you can use Sybase SQL Anywhere on QNX as following: CFLAGS=-DODBC_QNX 
LDFLAGS=-lunix CUSTOM_ODBC_LIBS="-ldblib -lodbc" ./configure 
--with-custom-odbc=/usr/lib/sqlany5 

Unified ODBC 

--disable-unif ied-odbc 

Disables the Unified ODBC module, which is a common interface to all the databases with ODBC-based interfaces, 
such as Solid and Adabas D. It also works for normal ODBC libraries. Has been tested with iODBC, Solid, Adabas 
D and Sybase SQL Anywhere. Requires that one (and only one) of these modules or the Velocis module is enabled, 
or a custom ODBC library specified. This option is only applicable if one of the following options is used: 
— with-iodbc , — with-solid , — with-adabas , — with-velocis , or — with-custom-odbc . 

See also Unified ODBC Configuration Directives in the configuration file . 

LDAP 

— with-ldap=DTi^ 

Includes LDAP (Lightweight Directory Access Protocol) support. The parameter is the LDAP base install directory, 
defaults to /usr/ local /Idap. 

More information about LDAP can be found in RFC 1777 and RFC1778 . 

Other configure options 

--witli-mcrypt=DJi? 

— with-mcrypt 

Include support for the mcrypt library. See the mcrypt documentation for more information. If you use the optional 
DIR argument, PHP will look for mcrypt.h in D Ji^include. 

-enable-sysvsem 

--enable -sysvsem 

Include support for Sys V semaphores (supported by most Unix derivates). See the Semaphore and Shared Memory 
documentation for more information. 



-enable-sysvshm 

--enable -sysvshm 

Include support for Sys V shared memory (supported by most Unix derivates). See the Semaphore and Shared 
Memory documentation for more information. 

"With-xml 

— with-xml 

Include support for a non-validating XML parser using James Clark's expat library . See the XML function reference 
for details. 

-enable-maintainer-mode 

--enable-maintainer-mode 
Turns on extra dependencies and compiler warnings used by some of the PHP developers. 

"With-system-regex 

— with-system-regex 

Uses the system's regular expression library rather than the bundled one. If you are building PHP as a server module, 
you must use the same library v^/hen building PHP as when linking the server. Enable this if the system's library 
provides special features you need. It is recommended that you use the bundled library if possible. 

"With-config-file-path 

--with-conf ig-f ile-path=DIR 
The path used to look for the configuration file when PHP starts up. 

"With-exec-dir 

--with-exec-dir=DIiR 

Only allow running of executables in DIR when in safe mode. Defaults to /usr/local/bin. This option only 
sets the default, it may be changed with the safe_mode_exec_dir directive in the configuration file later. 

-enable-debug 

--enable -debug 

Enables extra debug information. This makes it possible to gather more detailed information when there are 
problems with PHP. (Note that this doesn't have anything to do with debugging facilities or information available to 
PHP scripts.) 



-enable-safe-mode 

--enable -safe-mode 

Enables "safe mode" by default. This imposes several restrictions on what PHP can do, such as opening only files 
within the document root. Read the Security chapter for more more information. CGI users should always enable 
secure mode. This option only sets the default, it may be enabled or disabled with the safe_mode directive in the 
configuration file later. 

-enable-track-vars 

--enable -track-vars 

Makes PHP keep track of where GET/POST/cookie variables come from in the arrays HTTP_GET_VARS, 
HTTP_POST_VARS and HTTP_COOKIE_VARS. This option only sets the default, it may be enabled or disabled 
with the track_vai"s directive in the configuration file later. 

-enable-magic-quotes 

— enable-magic-quotes 

Enable magic quotes by default. This option only sets the default, it may be enabled or disabled with the 
magic_quotes_runtime directive in the configuration file later. See also the magic_q uotes_gpc and the 
magic_quotes_sybase directives. 

-enable-debugger 

--enable -debugger 

Enables the internal PHP debugger support. This feature is still in an experimental state. See also the Debugger 
Configuration directives in the configuration file . 

-enable-discard-path 

--enable -discard-path 

If this is enabled, the PHP CGI binary can safely be placed outside of the web tree and people will not be able to 
circumvent .htaccess security. Read the section in the security chapter about this option. 

-enable-bcmath 

--enable-bcmath 
Enables be style arbitrary precision math functions. See also the bcmath. scale option in the configuration file . 

-enable-force-cgi-redirect 

--enab le-force- eg i- redirect 
Enable the security check for internal server redirects. You should use this if you are running the CGI version with 



Apache. 

When using PHP as a CGI binary, PHP by default always first checks that it is used by redirection (for example 
under Apache, by using Action directives). This makes sure that the PHP binary cannot be used to bypass standard 
web server authentication procedures by calling it directly, like 

http : //my .host /cgi -bin/ php/ secret /doc .html. This example accesses 

http : / /my . host / secret /doc . html but does not honour any security settings enforced by httpd for 

directory /secret. 

Not enabling option disables the check and enables bypassing httpd security and authentication settings. Do this 
only if your server software is unable to indicate that a safe redirection was done and all your files under your 
document root and user directories may be accessed by anyone. 

Read the section in the security chapter about this option. 

"disable-short-tags 

--disable-short -tags 

Disables the short form < ? ? > PHP tags. You must disable the short form if you want to use PHP with XML. With 
short tags disabled, the only PHP code tag is <?php ?>. This option only sets the default, it may be enabled or 
disabled with the short_open_tag directive in the configuration file later. 

-enable-url-includes 

--enable -url- includes 

Makes it possible to run code on other HTTP or FTP servers directly from PHP with includeQ . See also the 
include_path option in the configuration file . 

"disable-syntax-hl 

--disable-syntax-hl 
Turns off syntax highlighting. 

CPPFLAGS and LDFLAGS 

To make the PHP installation look for header or library files in different directories, modify the CPPFLAGS and 
LDFLAGS environment variables, respectively. If you are using a sensible shell, you should be able to do 
LDFLAGS=-L/my/lib/dir CPPFLAGS=-I/my/include/dir ./configure 



Building 



When PHP is configured, you are ready to build the CGI executable or the PHP library. The command make should 
take care of this. If it fails and you can't figure out why, see the Problems section . 



Testing 



If you have built PHP as a CGI program, you may test your build by typing make test. It is always a good idea to 
test your build. This way you may catch a problem with PHP on your platform early instead of having to struggle 
with it later. 



Benchmarking 



If you have built PHP as a CGI program, you may benchmark your build by typing make bench. Note that if safe 
mode is on by default, the benchmark may not be able to finish if it takes longer then the 30 seconds allowed. This is 
because the set_time_limit() can not be used in safe mode. Use the max_execution_time configuration setting to 
control this time for your own scripts, make bench ignores the configuration file . 

Prev Home Next 

Installation Up Installation on Windows 

95/98/NT systems 



PHP Manual 

Prev Chapter 2. Installation Next 



Installation on Windows 95/98/NT 
systems 

This install guide will help you install and configure PHP on your Windows 9x/NT webservers. 
This guide was compiled by Bob Silva . The latest revision can be found at 
http://www.umesd.kl2.or.us/php/win32install.html . 

This guide provides installation support for: 

q Personal Web Server (Newest version recommended) 

q Internet Information Server 3 or 4 

q Apache 1.3.x 

q OmniHTTPd2.0bl 



General Installation Steps 



The following steps should be performed on all installations before the server specific instructions. 

q Extract the distribution file to a directory of your choice. "C:\PHP3\" is a good start. 

q Copy the file, 'php3.ini-dist' to your '%WINDOWS%' directory and rename it to 'php3.ini'. 
Your '%WINDOWS%' directory is typically: 

c:\windows for Windows 95/98 
c:\winnt or c:\winnt40 for NT servers 

q Edit your 'php3.ini' file: 

r You will need to change the 'extension_dir' setting to point to your php-install-dir, or 
where you have placed your 'php3_*.dir files, ex: c:\php3 

r If you are using Omni Httpd, do not follow the next step. Set the 'doc_root' to point to 
your webservers document_root. ex: c:\apache\htdocs or c:\webroot 

r Choose which modules you would like to load when PHP starts. You can uncomment 
the: 'extension=php3_*.dir lines to load these modules. Some modules require you to 
have additional libraries installed on your system for the module to work correctly. 
The PHP FAQ has more information on where to get supporting libraries. You can 
also load a module dynamically in your script using: dl("php_*.dU"); 

r On PWS and IIS, you can set the browscap.ini to point to: 

'c:\windows\system\inetsrv\browscap.ini' on Windows 95/98 and 



'c:\winnt\system32\inetsrv\browscap.ini' on NT Server. Additional information on 
using the browscap functionality in PHP can be found at this mirror , select the 
"source" button to see it in action. 

The DLLs for PHP extensions are prefixed with 'php3_'. This prevents confusion between PHP 
extensions and their supporting libraries. 

Windows 95/98/NT and PWS/IIS 3 

The recommended method for configuring these servers is to use the INF file included with the 
distribution (php_iis_reg.inf). You may want to edit this file and make sure the extensions and PHP 
install directories match your configuration. Or you can follow the steps below to do it manually. 

WARNING: These steps involve working directly with the windows registry. One error here can 
leave your system in an unstable state. We highly recommend that you back up your registry first. 
The PHP Development team will not be held responsible if you damage your registry. 

q Run Regedit. 

q Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet 
/Services /W3Svc /Parameters /ScriptMap. 

q On the edit menu select: New->String Value. 

q Type in the extension you wish to use for your php scripts, ex: . php3 

q Double click on the new string value and enter the path to php . exe in the value data field, 
ex: c : \php3\php . exe %s %s. The '%s %s' is VERY important, PHP will not work 
properly without it. 

q Repeat these steps for each extension you wish to associate with PHP scripts. 

q Now navigate to: HKEY_CLASSES_ROOT 

q On the edit menu select: New->Key. 

q Name the key to the extension you setup in the previous section, ex: . php 3 

q Highlight the new key and in the right side pane, double click the "default value" and enter 

phpf ile. 

q Repeat the last step for each extension you set up in the previous section. 

q Now create another New->Key under HKEY_CLASSES_ROOT and name it phpf ile. 

q Highlight the new key phpf ile and in the right side pane, double click the "default value" 
and enter PHP Script. 

q Right click on the phpf ile key and select New->Key, name it Shell. 

q Right click on the Shell key and select New->Key, name it open. 

q Right click on the open key and select New->Key, name it command. 



q Highlight the new key command and in the right side pane, double click the "default value" 
and enter the path to php . exe. ex: c:\php3\php.exe -q %1. (don't forget the %1). 

q Exit Regedit. 

PWS and IIS 3 users now have a fully operational system. IIS 3 users can use a nifty tool from 
Steven Genusa to configure their script maps. 

Windows NT and IIS 4 

To install PHP on an NT Server running IIS 4, follow these instructions: 

q In Internet Service Manager (MMC), select the Web site or the starting point directory of an 
application. 

q Open the directory's property sheets (by right clicking and selecting properties), and then 
click the Home Directory, Virtual Directory, or Directory tab. 

q Click the Configuration button, and then click the App Mappings tab. 

q Click Add, and in the Executable box, type: c : \path-to-php-dir\php . exe %s %s. 
You MUST have the %s %s on the end, PHP will not function properly if you fail to do this. 

q In the Extension box, type the file name extension you want associated with PHP scripts. 
(You must repeat step 5 and 6 for each extension you want accociated with PHP scripts. 

( . php 3 and . phtml are common) 

q Set up the appropriate security. (This is done in Internet Service Manager), and if your NT 
Server uses NTFS file system, add execute rights for I_USR_ to the directory that contains 

php . exe. 

Windows 9x/NT and Apache 1.3.x 

You must edit your srm . conf or httpd . conf to configure Apache to work with the PHP CGI 
binary. 

Although there can be a few variations of configuring PHP under Apache, this one is simple 
enough to be used by the newcomer. Please consult the Apache Docs for further configuration 
directives. 

q ScriptAlias /php3/ "c : /path-to-php-dir/ " 

q AddType application/x-httpd-php3 .php3 

q AddType application/x-httpd-php3 .phtml 

q Action application/x-httpd-php3 " /php3/php . exe" 

To use the source code highlighting feature, simply create a PHP script file and stick this code in: 

<?php show_source ( "original_php_script .php3" ) ; ?>. Substitute 
original_php_script . php3 with the name of the file you wish to show the source of. (this 



is only one way of doing it). Note: On Win-Apactie all back slashes in a path statement such as: 
"c:\directory\file.ext", must be converted to forward slashes. 

Omni HTTPd 2.0b1 for Windows 

This has got to be the easiest config there is: 

Step 1 : Install Omni server 

Step 2: Right click on the blue OmniHTTPd icon in the system tray and select Properties 

Step 3: Click on Web Server Global Settings 

Step 4: On the 'External' tab, enter: virtual = .php3 | actual = 

c : \path-to-php-dir\php . exe 

Step 5: On the Mime tab, enter: virtual = wwwserver/stdcgi | actual = .php3 

Step 6: Click OK 

Repeat steps 2 - 6 for each extension you want to associate with PHP. 

PHP l\/lodules 

Table 2-1. PHP Modules 



php3_calendar.dll 


Calendar conversion functions 


php3_crypt.dll 


Crypt functions 


php3_dbase.dll 


DBase functions 


php3_dbm.dll 


GDBM emulation via Berkely DB2 library 


php3_filepro.dll 


READ ONLY access to filepro databases 


php3_gd.dll 


GD Library functions for gif manipulation 


php3_hyperwave.dll 


HyperWave functions 


php 3_imap4r2 . dll 


IMAP 4 functions 


php3_ldap.dll 


LDAP functions 


php3_msqll.dll 


mSQL 1 client 


php3_msql2.dll 


mSQL 2 client 


php3_mssql.dll 


MSSQL client (requires MSSQL DB-Libraries 


php3_mysql.dll 


MySQL functions 


php3_nsmail.dll 


Netscape mail functions 


php3_oci73.dll 


Oracle functions 


php3_snmp.dll 


SNMP get and walk functions (NT only!) 


php3_zlib.dll 


7\ ib functions 



Prev 

Installation on UNIX systems 



Home 
Up 



Next 
Problems? 




PHP Manual 

Prev Next 



XV. Encryption functions 



rhese functions are not supported in 
pHP Lite edition. 

^ook at the functions manual-page t( 
^e if possible workaround exists, 



These functions work using mcrypt . 

This is an interface to the mcrypt library, which supports a wide variety of block algorithms such as DBS, 
TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SKI 28, TWOFISH, TEA, RC2 and GOST in 
CBC, OFB, CFB and ECB cipher modes. Additionally, it supports RC6 and IDEA which are considered 
"non-free". 

To use it, download libmcrypt-x.x.tar.gz from here and follow the included installation instructions. You need to 
compile PHP with the --with-mcrypt parameter to enable this extension. 

mcrypt can be used to encrypt and decrypt using the above mentioned ciphers. The four important mcrypt 
commands ( mcrypt_cfb() , mcrypt_cbc() , mcrypt_ecb() , and mcrypt_ofb() ) can operate in both modes which are 
named MCRYPT_ENCRYPT and MCRYPT_DECRYPT, respectively. 
Example 1. Encrypt an input value with TripleDES in ECB mode 

<?php 

$key = "this is a very secret key"; 

$input = "Let us meet at 9 o'clock at the secret place."; 

$encrypted_data = mcrypt_ecb (MCRYPT_TripleDES, $key, $input, MCRYPT_ENCRYPT) ; 
?> 

This example will give you the encrypted data as a string in $encrypted_data. 

mcrypt can operate in four cipher modes (CBC, OFB, CFB, and ECB). We will outline the normal use for each of 
these modes. For a more complete reference and discussion see Applied Cryptography by Schneier (ISBN 
0-471-11709-9). 

q ECB (electronic codebook) is suitable for random data, such as encrypting other keys. Since data there is 
short and random, the disadvantages of ECB have a favorable negative effect. 

q CBC (cipher block chaining) is especially suitable for encrypting files where the security is increased over 
ECB significantly. 

q CFB (cipher feedback) is the best mode for encrypting byte streams where single bytes must be encrypted. 

q OFB (output feedback) is comparable to CFB, but can be used in applications where error propagation 
cannot be tolerated. 

PHP does not support encrypting/decrypting bit streams currently. As of now, PHP only supports handling of 
strings. 

For a complete list of supported ciphers, see the defines at the end of mcrypt.h. The general rule is that you can 
access the cipher from PHP with MCRYPT_ciphername. 



Here is a short list of ciphers which are currently supported by the mcrypt extension. If a cipher is not listed here, 
but is listed by mcrypt as supported, you can safely assume that this documentation is outdated. 

q MCRYPT_BLOWFISH 

q MCRYPT_DES 

q MCRYPT_TripleDES 

q MCRYPT_ThreeWAY 

q MCRYPT_GOST 

q MCRYPT_CRYPT 

q MCRYPT_DES_COMPAT 

q MCRYPT_SAFER64 

q MCRYPT_SAFER128 

q MCRYPT_CAST128 

q MCRYPT_TEAN 

q MCRYPT_RC2 

q MCRYPT_TWOFISH (for older mcrypt 2.x versions) 

q MCRYPT_TWOFISH128 (TWOFISHxxx are available in newer 2.x versions) 

q MCRYPT_TWOFISH192 

q MCRYPT_TWOFISH256 

q MCRYPT_RC6 

q MCRYPTJDEA 

You must (in CFB and OFB mode) or can (in CBC mode) supply an initialization vector (IV) to the respective 
cipher function. The IV must be unique and must be the same when decrypting/encrypting. With data which is 
stored encrypted, you can take the output of a function of the index under which the data is stored (e.g. the MD5 
key of the filename). Alternatively, you can transmit the IV together with the encrypted data (see chapter 9.3 of 
Applied Cryptography by Schneier (ISBN 0-471-11709-9) for a discussion of this topic). 

Table of Contents 

// mcrypt_get_cipher_name Get the name of the specified cipher 

// mcrvpt_get_block_size Get the block size of the specified cipher 

//mcrypt get key size Get the key size of the specified cipher 

// mcrypt_create_iv Create an initialization vector (IV) from a random source 

// mcrypt_cbc Encrypt/decrypt data in CBC mode 

// mcrypt_cfb Encrypt/decrypt data in CFB mode 

// mcrypt_ecb Encrypt/decrypt data in ECB mode 

// mcrypt_ofb Encrypt/decrypt data in OFB mode 

Prey Home Next 

dl IJg mcrypt_get_cipher_name 



PHP Manual 

Prev Next 



XLVIII. Semaphore and shared memory 
functions 



These functions are not suppc 

PHP Lite edition. 

Look at the functions manual-page to 

^^^ossibl^wo^araun^xists™ 




This module provides semaphore functions using System V semaphores. Semaphores may be used 
to provide exclusive access to resources on the current machine, or to limit the number of processes 
that may simultaneously use a resource. 

This module provides also shared memory functions using System V shared memory. Shared 
memory may be used to provide access to global variables. Different httpd-daemons and even other 
programs (such as Perl, C, ...) are able to access this data to provide a global data-exchange. 
Remember, that shared memory is NOT safe against simultaneous access. Use semaphores for 
synchronization. 

Table 1. Limits of shared memory by the Unix OS 



SHMMAX 



SHMMIN 



SHMMNI 



SHMSEG 



max size of shared memory, normally 131072 bytes 



minimum size of shared memory, normally 1 byte 



max amount of shared memory segments, normally 100 



max amount of shared memory per process, normally 6 



Table of Contents 

// sem_get get a semaphore id 

// sem_acquire acquire a semaphore 

// sem_release release a semaphore 

// shm_attach Creates or open a shared memory segment 

// shm_detach Disconnects from shared memory segment 

// shm_remove Removes shared memory from Unix systems 

// shm_put_var Inserts or updates a variable in shared memory 

// shm_get_var Returns a variable from shared memory 

// shm_remove_var Removes a variable from shared memory 



Prev Home Next 

sql_regcase Ug sem_get 



PHP Manual 

Prev Next 



LVIII. XML parser functions 




ese functions are not supported in the 
P Lite edition. 

ok at the functions manual-page to 
possible workaround exists ^_ 



Introduction 

About XML 



XML (extensible Markup Language) is a data format for structured document interchange on the Web. It is a standard 
defined by The World Wide Web consortium (W3C). Information about XML and related technologies can be found at 
http://www.w3.org/XML/ . 

Installation 

This extension uses expat, which can be found at http://www.iclark.com/xml/ . The Makefile that comes with expat does 
not build a library by default, you can use this make rule for that: 

libexpat.a: $ (OBJS) 

ar -re $@ $ (OBJS) 
ranlib $@ 

A source RPM package of expat can be found at http://www.guardian.no/~ssb/phpxml.html . 

Note that if you are using Apache- 1.3.7 or later, you already have the required expat library. Simply configure PHP 
using --with-xml (without any additional path) and it will automatically use the expat library built into Apache. 

On UNIX, run configure with the --with-xml option. The expat library should be installed somewhere your compiler 
can find it. If you compile PHP as a module for Apache 1.3.9 or later, PHP will automatically use the bundled expat 
library from Apache. You may need to set CPPFLAGS and LDFLAGS in your environment before running configure if 
you have installed expat somewhere exotic. 

Build PHP. Tada! That should be it. 

About This Extension 

This PHP extension implements support for James Clark's expat in PHP. This toolkit lets you parse, but not validate, 
XML documents. It supports three source character encodings also provided by PHP: US-ASCII, ISO-8859-1 and 

UTF-8. UTF-16 is not supported. 

This extension lets you create XML parsers and then define handlers for different XML events. Each XML parser also 
has a few parameters you can adjust. 

The XML event handlers defined are: 
Table 1, Supported XML handlers 



PHP function to set handler 


Event description 


xml_set_element_handler() 


Element events are issued whenever the XML parser encounters start or 
end tags. There are separate handlers for start tags and end tags. 




xml_set_character_data_handler() 


Character data is roughly all the non-markup contents of XML 
documents, including whitespace between tags. Note that the XML parser 
does not add or remove any whitespace, it is up to the application (you) to 
decide whether whitespace is significant. 




xml_set_processing_instruction_handler() 


PHP programmers should be familiar with processing instructions (Pis) 
already. <?php ?> is a processing instruction, where php is called the "PI 
target". The handling of these are application-specific, except that all PI 
targets starting with "XML" are reserved. 




xml_set_default_handler() 


What goes not to another handler goes to the default handler. You will get 
things like the XML and document type declarations in the default 
handler. 




xml_set_unparsed_entity_decl_handler() 


This handler will be called for declaration of an unparsed (NDATA) 
entity. 




xml_set_notation_decl_handler() 


This handler is called for declaration of a notation. 




xml_set_external_entity_ref_handler() 


This handler is called when the XML parser finds a reference to an 
external parsed general entity. This can be a reference to a file or URL, 
for example. See the external entity example for a demonstration. 





Case Folding 



The element handler functions may get their element names case-folded. Case-folding is defined by the XML standard as 
"a process applied to a sequence of characters, in which those identified as non-uppercase are replaced by their uppercase 
equivalents". In other words, when it comes to XML, case-folding simply means uppercasing. 

By default, all the element names that are passed to the handler functions are case-folded. This behaviour can be queried 
and controlled per XML parser with the xml_parser_get_option() and xml_parser_set_option() functions, 
respectively. 

Error Codes 



The following constants are defined for XML error codes (as returned by xml_parse() ): 

XML_ERROR_NONE 

XML_ERROR_NO_MEMORY 

XML_ERROR_SYNTAX 

XML_ERROR_NO_ELEMENTS 

XML_ERROR_INVALID_TOKEN 

XML_ERROR_UNCLOSED_TOKEN 

XML_ERROR_PARTIAL_CHAR 

XML_ERROR_TAG_MISMATCH 

XML_ERROR_DUPLIC ATE_ATTRIB UTE 

XML_ERROR_JUNK_AFTER_DOC_ELEMENT 

XML_ERROR_PARAM_ENTITY_REF 

XML_ERROR_UNDEFINED_ENTITY 

XML_ERROR_RECURSIVE_ENTITY_REF 

XML_ERROR_ASYNC_ENTITY 

XML_ERROR_BAD_CHAR_REF 

XML_ERROR_BINARY_ENTITY_REF 

XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF 

XML_ERROR_MISPLACED_XML_PI 

XML ERROR UNKNOWN ENCODING 



XML_ERROR_INCORRECT_ENCODING 

XML_ERROR_UNCLOSED_CDATA_SECTION 

XML_ERROR_EXTERNAL_ENTITY_HANDLING 

Character Encoding 

PHP's XML extension supports the Unicode character set through different character encoding?,. There are two types of 
character encodings, source encoding and target encoding. PHP's internal representation of the document is always 
encoded with UTF-8. 

Source encoding is done when an XML document is parsed . Upon creating an XML parser , a source encoding can be 
specified (this encoding can not be changed later in the XML parser's lifetime). The supported source encodings are 
ISO- 8859-1, US -ASCI I and UTF-8. The former two are single-byte encodings, which means that each character is 
represented by a single byte. UTF-8 can encode characters composed by a variable number of bits (up to 21) in one to 
four bytes. The default source encoding used by PHP is ISO-8859-1. 

Target encoding is done when PHP passes data to XML handler functions. When an XML parser is created, the target 
encoding is set to the same as the source encoding, but this may be changed at any point. The target encoding will affect 
character data as well as tag names and processing instruction targets. 

If the XML parser encounters characters outside the range that its source encoding is capable of representing, it will 
return an error. 

If PHP encounters characters in the parsed XML document that can not be represented in the chosen target encoding, the 
problem characters will be "demoted". Currently, this means that such characters are replaced by a question mark. 

Some Examples 

Here are some example PHP scripts parsing XML documents. 

XML Element Structure Example 

This first example displays the stucture of the start elements in a document with indentation. 
Example 1, Show XML Element Structure 

$file = "data.xml"; 
$depth = array 0; 

function startElement ($parser, $name, $attrs) { 
global $depth; 

for ($i = 0; $i < $depth [ $parser ] ; $i++) { 
print " " ; 

} 

print "$name\n"; 
$ depth [$parser]++; 
} 

function endElement ( $parser, $name) { 

global $depth; 

$ depth [$parser] --; 
} 

$xml_parser = xml_parser_create ( ) ; 

xml_set_element_handler ($xml_parser, "startElement", "endElement") ; 

if (!($fp = fopen($file, "r"))) { 

die ("could not open XML input"); 
} 



hile ($data = fread($fp, 4096)) { 

if ( ! xml_parse ($xml_parser, $data, feof($fp))) { 
die (sprintf ( "XML error: %s at line %d", 

xml_error_string (xml_get_error_code ($xml_parser ) ) , 
xml_get_current_line_number ($xml_parser) ) ) ; 



} 
} 
xml_parser_f ree ($xml_parser ) 



XML Tag Mapping Example 

Example 2. Map XML to HTML 

This example maps tags in an XML document directly to HTML tags. Elements not found in the "map 
array" are ignored. Of course, this example will only work with a specific XML document type. 

$file = "data.xml"; 
$map_array = array ( 

"BOLD" => "B", 

"EMPHASIS" => "I", 

"LITERAL" => "TT" 

) ; 

function startElement ($parser, $name, $attrs) { 

global $map_array; 

if ($htmltag = $map_array [$name] ) { 
print "<$htmltag>" ; 

} 
} 

function endElement ( $parser, $name) { 

global $map_array; 

if ($htmltag = $map_array [$name] ) { 
print "</$htmltag>" ; 

} 
} 

function characterData ($parser, $data) { 

print $data; 
} 

$xml_parser = xml_parser_create ( ) ; 

// use case-folding so we are sure to find the tag in $map_array 

xml_parser_set_option ($xml_parser, XML_OPTION_CASE_FOLDING, true) ; 

xml_set_element_handler ($xml_parser, "startElement" , "endElement" ) ; 

xml_set_character_data_handler ($xml_parser, "characterData" ) ; 

if (!($fp = fopen($file, "r"))) { 

die ("could not open XML input"); 
} 

while ($data = fread($fp, 4096)) { 

if ( ! xml_parse ($xml_parser, $data, feof($fp))) { 
die (sprintf ( "XML error: %s at line %d", 

xml_error_string (xml_get_error_code ($xml_parser ) ) , 
xml_get_current_line_number ($xml_parser) ) ) ; 



} 

} 

xml_parser_f ree ($xml_parser ) ; 

XML External Entity Example 

This example highlights XML code. It illustrates how to use an external entity reference handler to include and parse 
other documents, as well as how Pis can be processed, and a way of determining "trust" for Pis containing code. 

XML documents that can be used for this example are found below the example (xmltest . xml and 
xmltest2 . xml.) 

Example 3, External Entity Example 

$file = "xmltest . xml " ; 

function trustedFile ($f lie) { 

// only trust local files owned by ourselves 

if ( leregi ("^ ( [a-z] +) : //", $file) && f ileowner ($f lie) == getmyuidO) { 
return true; 

} 

return false; 
} 

function startElement ($parser, $name, $attribs) { 

print "<<font color=\ "#0000cc\ ">$name</f ont>" ; 
if (sizeof ($attribs) ) { 

while (list($k, $v) = each ($attribs) ) { 

print " <font color=\ "#009900\ ">$k</f ont>=\"<f ont 
color=\"#990000\">$v</font>\""; 
} 
} 
print "&gt ; "; 

} 

function endElement ( $parser , $name) { 

print "</<font color=\ "#0000cc\ ">$name</f ont>&gt ; " ; 
} 

function characterData ($parser, $data) { 

print "<b>$data</b>"; 
} 

function PIHandler ($parser, $target, $data) { 
switch (strtolower ($target ) ) { 
case "php" : 

global $parser_f lie; 

// If the parsed document is "trusted", we say it is safe 

// to execute PHP code inside it. If not, display the code 

// instead. 

if (trustedFile ($parser_f lie [$parser] ) ) { 

eval ($data) ; 
} else { 

printf ( "Untrusted PHP code: <i>%s</i>", htmlspecialchars ($data) ) ; 

} 
break; 

} 

} 



function def aultHandler ($parser, $data) { 

if (substr ($data, 0, 1) == "&" && substr ($data, -1, 1) == ";") { 

print f ( ' <f ont color="#aaOOaa">%s</f ont> ' , html special chars ( $data) ) ; 
} else { 

print f ( '<font size="-l">%s</font>' , html special chars ($data) ) ; 
} 
} 

function externalEntityRef Handler ( $parser, $openEntityNames, $base, $systemld, 

$publicld) { 
if ($systemld) { 

if ( ! list ($parser, $fp) = new_xml_parser ($systemld) ) { 

printf ( "Could not open entity %s at %s\n", $openEntityNames, 

$systemld) ; 
return false; 

} 

while ($data = fread($fp, 4096)) { 

if ( ! xml_parse ($parser, $data, feof($fp))) { 

printf ("XML error: %s at line %d while parsing entity %s\n", 
xml_error_string (xml_get_error_code ($parser) ) , 
xml_get_current_line_number ($parser) , $openEntityNames) ; 
xml_parser_f ree ($parser) ; 
return false; 
} 
} 

xml_parser_f ree ($parser) ; 
return true; 
} 

return false; 
} 



function new_xml_parser ($f lie) { 
global $parser_f lie; 

$xml_parser = xml_parser_create ( ) ; 

xml_parser_set_option ($xml_parser, XML_OPTION_CASE_FOLDING, 1) ; 
xml_set_element_handler ($xml_parser, "startElement " , "endElement " ) ; 
xml_set_character_data_handler ($xml_parser, "characterData" ) ; 
xml_set_processing_instruction_handler ($xml_parser , "PIHandler" ) ; 
xml_set_def ault_handler ($xml_parser, "def aultHandler" ) ; 
xml_set_external_entity_ref_handler ( $xml_parser, "externalEntityRef Handler" ) ; 

if (!($fp = @fopen($file, "r"))) { 
return false; 

} 

if ( ! is_array ($parser_f lie) ) { 

settype ($parser_f lie, "array") ; 
} 

$parser_f lie [ $xml_parser ] = $file; 
return array ($xml_parser, $fp) ; 
} 

if ( ! (list ($xml_parser, $fp) = new_xml_parser ($f lie) ) ) { 

die ("could not open XML input"); 
} 



print "<pre>"; 

while ($data = fread($fp, 4096)) { 

if ( ! xml_parse ($xml_parser, $data, feof($fp))) { 
die (sprintf ( "XML error: %s at line %d\n", 

xml_error_string (xml_get_error_code ($xml_parser ) ) , 
xml_get_current_line_number ($xml_parser) ) ) ; 



} 
} 

print "</pre>"; 
print "parse complete\n"; 
xml_parser_f ree ($xml_parser ) ; 

?> 

Example 4, xmltest,xml 

<?xml version= ' 1 . ' ?> 

<!DOCTYPE chapter SYSTEM "/ just /a/test . dtd" [ 

<!ENTITY plainEntity "FOO entity"> 

<!ENTITY systemEntity SYSTEM "xmltest2 . xml"> 

]> 

<chapter> 
<TITLE>Title SplainEntity; </TITLE> 
<para> 
<inf ormaltable> 
<tgroup cols="3"> 
<tbody> 
<row><entry>al</ entry xentry morerows="l ">bl</entry><entry>cl</ entry ></row> 
<row><entry>a2</entry><entry>c2</entry></row> 

<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> 
</tbody> 
</tgroup> 
</ informal table> 
</para> 
& systemEntity ; 
<sectl id="about"> 
<title>About this Document</title> 
<para> 
<! — this is a comment — > 

<?php print 'Hi! This is PHP version ' .phpversion ( ) ; ?> 
</para> 
</sectl> 
</chapter> 

This file is included from xmltest . xml: 
Example 5, xmltest2,xml 

<?xml version="l . 0"?> 

<!DOCTYPE foo [ 

<!ENTITY testEnt "test entity"> 

]> 

<foo> 

<element attrib="value"/> 

&testEnt ; 

<?php print "This is some more PHP code being executed."; ?> 
</foo> 

Table of Contents 



// xm 



// xm 



// xm 



//xm 



// xm 



// xm 



// xm 



//xm 



II xm 



II xm 



// xm 



// xm 



// xm 



// xm 



// xm 



// xm 



// xm 



// xm 



_parser_create create an XML parser 



set object Use XML Parser withing an object 



_set_element_handler set up start and end element handlers 



_set_character_data_handler set up character data handler 



_set processing instruction handler Set up processing instruction (PI) handler 



_set_default_handler set up default handler 



_set_unparsed_entitv_decl_handler Set up unparsed entity declaration handler 



_set_notation decl handler set up notation declaration handler 



.set_external_entity_ref_handler set up external entity reference handler 



_parse start parsing an XML document 



get error code get XML parser error code 



_error_string get XML parser error string 



_get_current_line_number get current line number for an XML parser 



get current column number Get current column number for an XML parser 



_get_current_byte_index get current byte index for an XML parser 



_parser_free Free an XML parser 



parser set option set options in an XML parser 



_parser_get_option get options from an XML parser 



//utf8 decode Converts a UTF-8 encoded string to ISO-8859-1 
//utf8 encode encodes an ISO-8859-1 string to UTF-8 



Prev Home Next 

wddx_deserialize Up xml_parser_create 



PHP Manual 

Prev Chapter 11. Control Structures Next 



JncludeQ 



The JncludeQ statement includes and evaluates the specified file. 

An important note about how this works is that when a file is IncludeQ ed or requireQ ed, parsing drops out of PHP 
mode and into HTML mode at the beginning of the target file, and resumes again at the end. For this reason, any code 
inside the target file which should be executed as PHP code must be enclosed within valid PHP start and end tags . 

This happens each time the IncludeQ statement is encountered, so you can use an IncludeQ statement within a looping 
structure to include a number of different files. 

$files = array (' first . inc ' , ' second. inc ' , ' third . inc ') ; 
for ($i = 0; $i < count ($files) ; $i++) { 

include $files[$i]; 
} 

IncludeQ differs from requireQ in that the include statement is re-evaluated each time it is encountered (and only when 
it is being executed), whereas the requireQ statement is replaced by the required file when it is first encountered, 
whether the contents of the file will be evaluated or not (for example, if it is inside an if statement whose condition 
evaluated to false). 

Because IncludeQ is a special language construct, you must enclose it within a statement block if it is inside a 
conditional block. 

/* This is WRONG and will not work as desired. */ 

if ($condition) 

include ( $f lie) ; 
else 

include ($other) ; 

/* This is CORRECT. */ 

if ($condition) { 

include ( $f lie) ; 
} else { 

include ($ other) ; 
} 

In both PHP3 and PHP4, it is possible to execute a return statement inside an IncludeQ ed file, in order to terminate 
processing in that file and return to the script which called it. Some differences in the way this works exist, however. 
The first is that in PHP3, the return may not appear inside a block unless it's a function block, in which case the 
return applies to that function and not the whole file. In PHP4, however, this restriction does not exist. Also, PHP4 
allows you to return values from IncludeQ ed files. You can take the value of the IncludeQ call as you would a normal 
function. This generates a parse error in PHP3. 



Example 11-1. includeQ in PHP3 and PHP4 

Assume the existence of the following file (named t est . inc) in the same directory as the main file: 

<?php 

echo "Before the return <br>\n"; 

if ( 1 ) { 

return 2 7; 

} 

echo "After the return <br>\n"; 

?> 

Assume that the main file (main . html) contains the following: 

<?php 

$retval = include ( 'test. inc' ); 

echo "File returned: ' $retval ' <br>\n" ; 

?> 

When main . html is called in PHP3, it will generate a parse error on line 2; you can't take the value of an includeQ in 
PHP3. In PHP4, however, the result will be: 

Before the return 
File returned: '27' 

Now, assume that main . html has been altered to contain the following: 

<?php 

include ( 'test. inc' ) ; 

echo "Back in main . html<br>\n" ; 

?> 

In PHP4, the output will be: 

Before the return 
Back in main.html 

However, PHP3 will give the following output: 

Before the return 
27Back in main.html 

Parse error: parse error in /home/torben/public_html/phptest /main . html on line 5 

The above parse error is a result of the fact that the return statement is enclosed in a non-function block within 
test . inc. When the return is moved outside of the block, the output is: 

Before the return 
27Back in main.html 

The spurious '27' is due to the fact that PHP3 does not support returning values from files like that. 

Please note that both includeQ and requireQ actually pull the contents of the target file into the calling script file itself; 
they do not call the target via HTTP or anything like that. So any variable set in the scope in which the inclusion 
happens will be available within the included file automatically, since it has effectively become a part of the calling 
file. 

include ( "f lie . inc?varone=l&vartwo=2" ); /* Won't work. */ 



$varone = 1; 
$vartwo = 2; 
include ( "file.inc" ) ; /* $varone and $vartwo will be available in file.inc */ 



Don't be misled by the fact that you can require or include files via HTTP using the Remote files feature; the above 
holds true regardless. 



See also readfileQ , requireQ , and virtualQ . 



Prev Home Next 

requireQ Up Functions 



PHP Manual 

Prev Chapter 2. Installation Next 



Problems? 

Read the FAQ 

Some problems are more common than others. The most common ones are listed in the PHP FAQ, 
found at http://www.php.net/FAQ.php3 



Bug reports 



If you think you have found a bug in PHP, please report it. The PHP developers probably don't 
know about it, and unless you report it, chances are it won't be fixed. You can report bugs using the 
bug-tracking system at http://www.php.net/bugs.php3 . 



Other problems 



If you are still stuck, someone on the PHP mailing list may be able to help you. You should check 
out the archive first, in case someone already answered someone else who had the same problem as 
you. The archives are available from the support page on http://www.php.net/ . To subscribe to the 
PHP mailing list, send an empty mail to php3-subscribe@lists.php.net . The mailing list address is 

php3@ lists .php .net. 

If you want to get help on the mailing list, please try to be precise and give the necessary details 
about your environment (which operating system, what PHP version, what web server, if you are 
running PHP as CGI or a server module, etc.), and preferably enough code to make others able to 
reproduce and test your problem. 

Prev Home Next 

Installation on Windows Up Configuration 

95/98/NT systems 



PHP Manual 

Prev Next 



set_time_limit 

set_time_limit ~ limit the maximum execution time 

Description 

void set_time_limit(int seconds); 

Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal 
error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the 
configuration file . If seconds is set to zero, no time limit is imposed. 

When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout 
is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is 
made, the script will run for a total of 45 seconds before timing out. 

Note that set_time_limit() has no effect when PHP is running in safe mode. There is no 
workaround other than turning off safe mode or changing the time limit in the configuration file . 

Prev Home Next 

set_magic_quotes_runtime Up POSIX functions 



PHP Manual 

Prev Chapter 4. Security Next 



Apache module 



When PHP is used as an Apache module it inherits Apache's user permissions (typically those of 
the "nobody" user). 

Prev Home Next 

Security U^ Language Reference 



PHP Manual 

Prev Next 



phpinfo 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

phpinfo ~ Output lots of PHP information. 

Description 



int phpinf o(void); 

Outputs a large amount of information about the current state of PHP. This includes information 
about PHP compilation options and extensions, the PHP version, server information and 
environment (if compiled as a module), the PHP environment, OS version information, paths, 
master and local values of configuration options, HTTP headers, and the GNU Public License. 

See also phpversionQ . 

Prev Home Next 

getrusage Up phpversion 



PHP Manual 

Prev Next 



getrusage 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getrusage ~ Get the current resource usages. 

Description 

array getrusage(int [who]); 

This is an interface to getrusage(2). It returns an associative array containing the data returned from 
the system call. If who is 1, getrusage will be called with RUSAGE_CHILDREN. All entries are 
accessible by using their documented field names. 

Example 1. Getrusage Example 

$dat = getrusage (); 

echo $dat [ "ru_nswap" ] ; # number of swaps 

echo $dat [ "ru_ma jf It " ] ; # number of page faults 

echo $dat [ "ru_utime . tv_sec" ] ; # user time used (seconds) 

echo $dat [ "ru_utime . tv_usec" ] ; # user time used (microseconds) 

See your system's man page for more details. 

Prev Home Next 

getmyuid Up phpinfo 



PHP Manual 

Prev Next 



phpversion 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

phpversion ~ Get the current PHP version. 

Description 

string phpversion(void); 

Returns a string containing the version of the currently running PHP parser. 

Example 1. phpversion() example 

// prints e.g. 'Current PHP version: 3.0rel-dev' 
echo "Current PHP version: " .phpversion () ; 

See also phpinfoQ . 

Prev Home Next 

phpinfo U^ putenv 



PHP Manual 

Prev Next 



XLII. PHP options & information 

Table of Contents 

error_log send an error message somewhere 

error_reporting set which PHP errors are reported 

// extension_loaded find out whether an extension is loaded 

getenv Get the value of an environment variable 

get_cfg_var Get the value of a PHP configuration option. 

// get_current_user Get the name of the owner of the current PHP script. 

// get_magic_quotes_gpc Get the current active configuration setting of magic quotes gpc. 

// get_magic_quotes_runtime Get the current active configuration setting of 

magic_quotes_runtime. 

// getlastmod Get time of last page modification. 

// getmyinode Get the inode of the current script. 

// getmypid Get PHP's process ID. 

// getmyuid Get PHP script owner's UID. 

// getrusage Get the current resource usages. 

// phpinfo Output lots of PHP information. 

// phpversion Get the current PHP version. 

putenv Set the value of an environment variable. 

// set_magic_quotes_runtime Set the current active configuration setting of 

magic_quotes_runtime. 

set_time_limit limit the maximum execution time 

Prev Home Next 

Pattern Syntax Ug error_log 



PHP Manual 

Prev Next 



get_cfg_var 

get_cfg_var ~ Get the value of a PHP configuration option. 

Description 

string get_cf g_var(string varname); 

Returns tlie current value of the PHP configuration variable specified by varname, or false if an 
error occurs. 

It will not return configuration information set when the PHP was compiled, or read from an 
Apache configuration file (using the php3_configuration_option directives). 

To check whether the system is using a configuration file , try retrieving the value of the 
cfg_file_path configuration setting. If this is available, a configuration file is being used. 

Prev Home Next 

getenv Up get_current_user 



PHP Manual 

Prev Next 



getenv 

getenv ~ Get the value of an environment variable 

Description 



string getenv(string varname); 

Returns the value of the environment variable varname, or false on an error. 

$ip = getenv ("REMOTE_ADDR") ; // get the ip number of the user 

You can see a list of all the environmental variables by using phpinfoQ . You can find out what 
many of them mean by taking a look at the CGI specification , specifically the page on 
environmental variables . 

Prev Home Next 

extension_loaded Up get_cfg_var 



PHP Manual 

Prev Next 



get_current_user 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

get_current_user ~ Get the name of the owner of the current PHP script. 

Description 

string get_current_user(void); 

Returns the name of the owner of the current PHP script. 

See also getmyuidQ , getmypidQ , getmyinodeQ , and getlastmodQ . 

Prev Home Next 

get_cfg_var Ug get_magic_quotes_gpc 



PHP Manual 

Prev Chapter 11. Control Structures Next 



requireQ 



The requireQ statement replaces itself with the specified file, much like the C preprocessor's # include works. 

An important note about how this works is that when a file is includeQ ed or requireQ ed, parsing drops out of PHP 
mode and into HTML mode at the beginning of the target file, and resumes PHP mode again at the end. For this 
reason, any code inside the target file which should be executed as PHP code must be enclosed within valid PHP start 
and end tags . 

requireQ is not actually a function in PHP; rather, it is a language construct. It is subject to some different rules than 
functions are. For instance, requireQ is not subject to any containing control structures. For another, it does not return 
any value; attempting to read a return value from a requireQ call results in a parse error. 

Unlike includeQ , requireQ will always read in the target file, even if the line it's on never executes. If you want to 
conditionally include a file, use includeQ . The conditional statement won't affect the requireQ . However, if the line 
on which the requireQ occurs is not executed, neither will any of the code in the target file be executed. 

Similarly, looping structures do not affect the behaviour of requireQ . Although the code contained in the target file is 
still subject to the loop, the requireQ itself happens only once. 

This means that you can't put a requireQ statement inside of a loop structure and expect it to include the contents of a 
different file on each iteration. To do that, use an includeQ statement. 

require ( 'header. inc' ); 

Please note that both includeQ and requireQ actually pull the contents of the target file into the calling script file 
itself; they do not call the target via HTTP or anything like that. So any variable set in the scope in which the 
inclusion happens will be available within the included file automatically, since it has effectively become a part of the 
calling file. 

require ( "f ile . inc?varone=l&vartwo=2 " ); /* Won't work. */ 

$varone = 1; 
$vartwo = 2; 
require ( "file. inc" ) ; /* $varone and $vartwo will be available in file. inc */ 

Don't be misled by the fact that you can require or include files via HTTP using the Remote files feature; the above 
holds true regardless. 

In PHP3, it is possible to execute a return statement inside a requireQed file, as long as that statement occurs in 
the global scope of the requireQed file. It may not occur within any block (meaning inside braces ({ }). In PHP4, 
however, this ability has been discontinued. If you need this functionality, see includeQ . 

Prev Home Next 

switch Up includeQ 



PHP Manual 

Prev Next 



Chapter 12. Functions 



Table of Contents 

User-defined functions 
Function arguments 
Returning values 

old function 
Variable functions 

User-defined functions 

A function may be defined using syntax such as the following: 

function foo ($arg_l, $arg_2, ..., $arg_n) { 

echo "Example f unction . \n" ; 

return $retval; 
} 

Any valid PHP code may appear inside a function, even other functions and class definitions. 

In PHP3, functions must be defined before they are referenced. No such requirement exists in 
PHP4. 

PHP does not support function overloading, nor is it possible to undefine or redefine 
previously-declared functions. 

PHP3 does not support variable numbers of arguments to functions, although default arguments are 
supported (see Default argument values for more information). PHP4 supports both: see 
Variable-length argument lists and the function references for func_num_args() , func_get_arg() , 
and func_get_args() for more information. 

Prev Home Next 

JncludeQ Up Function arguments 



PHP Manual 

Prev Next 



Chapter 11. Control Structures 

Table of Contents 

if 

else 

elseif 

Alternative syntax for control structures 

while 

do . .while 

for 

break 

continue 

switch 

requireQ 

JncludeQ 

Any PHP script is built out of a series of statements. A statement can be an assignment, a function 
call, a loop, a conditional statement of even a statement that does nothing (an empty statement). 
Statements usually end with a semicolon. In addition, statements can be grouped into a 
statement-group by encapsulating a group of statements with curly braces. A statement-group is a 
statement by itself as well. The various statement types are described in this chapter. 

if 

The i f construct is one of the most important features of many languages, PHP included. It allows 
for conditional execution of code fragments. PHP features an i f structure that is similar to that of 
C: 

if (expr) 

statement 

As described in the section about expressions, expr is evaluated to its truth value. If expr evaluates 
to TRUE, PHP will execute statement, and if it evaluates to FALSE - it'll ignore it. 

The following example would display a is bigger than b if ^ a is bigger than ^b: 

if ($a > $b) 

print "a is bigger than b"; 



Often you'd want to have more than one statement to be executed conditionally. Of course, there's 
no need to wrap each statement with an i f clause. Instead, you can group several statements into a 
statement group. For example, this code would display a is bigger than b if ^a is bigger 
than $b, and would then assign the value of $a into $b: 

if ($a > $b) { 

print "a is bigger than b"; 

$b = $a; 
} 

If statements can be nested indefinitely within other i f statements, which provides you with 
complete flexibility for conditional execution of the various parts of your program. 

Prev Home Next 

String Operators Up else 



PHP Manual 

Prev Next 



Chapter 19. Using remote files 

As long as support for the "URL fopen wrapper" is enabled when you configure PHP (which it is 
unless you explicitly pass the — disable-url-f open-wrapper flag to configure), you can use 
HTTP and FTP URLs with most functions that take a filename as a parameter, including the 
requireQ and includeQ statements. 

Note: You can't use remote files in includeQ and requireQ statements on Windows. 

For example, you can use this to open a file on a remote web server, parse the output for the data you 
want, and then use that data in a database query, or simply to output it in a style matching the rest of 
your website. 

Example 19-1. Getting the title of a remote page 

<?php 

$file = f open ( "http : //www. php . net /" , "r"); 
if (!$file) { 

echo "<p>Unable to open remote file.\n"; 

exit; 

} 

while ( !feof ($file) ) { 

$line = fgets($file, 1024); 

/* This only works if the title and its tags are on one line. */ 
if (eregi ("<title> ( . *) </title>", $line, $out)) { 
$title = $out [1] ; 
break; 
} 
} 

f close ($f lie) ; 
?> 



You can also write to files on an FTP as long you connect as a user with the correct access rights, and 
the file doesn't exist already. To connect as a user other than 'anonymous', you need to specify the 
username (and possibly password) within the URL, such as 

'ftp://user:password@ ftp.example.com/path/to/file'. (You can use the same sort of syntax to access 
files via HTTP when they require Basic authentication.) 



Example 19-2. Storing data on a remote server 

<?php 

$file = f open ( "ftp : //ftp .php . net/incoming/outputf ile" , "w"); 
if (!$file) { 

echo "<p>Unable to open remote file for writing. \n"; 

exit; 

} 

/* Write the data here. */ 
fputs ($file, "$HTTP_USER_AGENT\n") ; 
f close ($f ile) ; 
?> 



Note: You might get the idea from the example above to use this technique to write to a 
remote log, but as mentioned above, you can only write to a new file using the URL 
fopen() wrappers. To do distributed logging like that, you should take a look at syslogQ . 

Prev Home Next 

PUT method support Up Connection handling 



PHP Manual 

Prev Next 



readfile 

readfile ~ output a file 

Description 

int readf ile(string filename, int [use_include_path]); 

Reads a file and writes it to standard output. 

Returns the number of bytes read from the file. If an error occurs, false is returned and unless the 
function was called as ©readfile, an error message is printed. 

If filename begins with "http://" (not case sensitive), an HTTP 1.0 connection is opened to the 
specified server and the text of the response is written to standard output. 

Does not handle HTTP redirects, so you must include trailing slashes on directories. 

If filename begins with "ftp://" (not case sensitive), an ftp connection to the specified server is 
opened and the requested file is written to standard output. If the server does not support passive 
mode ftp, this will fail. 

If filename begins with neither of these strings, the file will be opened from the filesystem and 
its contents written to standard output. 

You can use the optional second parameter and set it to "1", if you want to search for the file in the 
include_path , too. 

See also fpassthruQ , fileQ , fopenQ , includeQ , requireQ , and virtualQ . 

Prev Home Next 

popen Up readlink 



PHP Manual 

Prev Next 



virtual 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

virtual ~ Perform an Apache sub-request 

Description 

int virtual (string filename) ; 

virtualO is an Apache-specific function which is equivalent to <!~#include virtual... ~> in 
mod_include. It performs an Apache sub-request. It is useful for including CGI scripts or .shtml 
files, or anything else that you would parse through Apache. Note that for a CGI script, the script 
must generate valid CGI headers. At the minimum that means it must generate a Content-type 
header. For PHP files, you need to use includeQ or requireQ ; virtualQ cannot be used to include a 
document which is itself a PHP file.. 

Prev Home Next 

getallheaders U^ Arbitrary precision mathematics 

functions 



PHP Manual 

Prev Next 



exit 

exit ~ Terminate current script 

Description 

void exit(void); 

This language construct terminates parsing of the script. It does not return. 

Prev Home Next 

eval U^ func_get_arg 



PHP Manual 

Prev Next 



eval 

eval ~ Evaluate a string as PHP code 

Description 

void eva 1 (string code_str); 

eval() evaluates the string given in code_str as PHP code. Among other things, this can be 
useful for storing code in a database text field for later execution. 

There are some factors to keep in mind when using eval(). Remember that the string passed must be 
valid PHP code, including things like terminating statements with a semicolon so the parser doesn't 
die on the line after the eval(), and properly escaping things in code_str. 

Also remember that variables given values under eval() will retain these values in the main script 
afterwards. 

Example 1. eval() example - simple text merge 

<?php 

$string = ' cup ' ; 

$name = ' coffee ' ; 

$str = 'This is a $string with my $name in it . <br> ' ; 

echo $str; 

eval ( "\$str = \"$str\";" ); 

echo $str; 

?> 

The above example will show: 

This is a $string with my $name in it. 
This is a cup with my coffee in it. 



Prev Home Next 

die U^ exit 



PHP Manual 

Prev Next 



func_get_arg 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

func_get_arg ~ Return an item from the argument Hst. 

Description 

int f unc_get_arg(int arg_num); 

Returns the argument which is at the arg_num'th offset into a user-defined function's argument 
Hst. Function arguments are counted starting from zero. func_get_arg() will generate a warning if 
called from outside of a function definition. 

If arg_num is greater than the number of arguments actually passed, a warning will be generated 
and func_get_arg() will return FALSE. 

<?php 

function f oo ( ) { 

$numargs = f unc_num_args () ; 

echo "Number of arguments: $numargs<br>\n" ; 

if ( $numargs >= 2 ) { 

echo "Second argument is: " . f unc_get_arg ( 1 ) . "<br>\n"; 

} 
} 

f oo ( 1, 2, 3 ) ; 
?> 



func_get_arg() may be used in conjunction with func_num_args() and func_get_args() to allow 
user-defined functions to accept variable-length argument lists. 

Note: This function was added in PHP 4. 

Prev Home Next 

exit Up func_get_args 



PHP Manual 

Prev Next 



XXXII. Miscellaneous functions 

These functions were placed here because none of the other categories seemed to fit. 

Table of Contents 

connection_aborted Returns true if cHent disconnected 

connection_status Returns connection status bitfield 

connection_timeout Return true if script timed out 

define Defines a named constant. 

defined Checks whether a given named constant exists. 

die Output a message and terminate the current script 

eval Evaluate a string as PHP code 

exit Terminate current script 

// func_get_arg Return an item from the argument list. 

// func_get_args Returns an array comprising a function's argument list. 

// func_num_args Returns the number of arguments passed to the function. 

function_exists Return true if the given function has been defined 

// get_browser Tells what the user's browser is capable of. 

ignore_user_abort Set whether a client disconnect should abort script execution 

// iptcparse Parse a binary IPTC http : //www . xe . net/iptc/ block into single tags. 

leak Leak memory 

// pack pack data into binary string 

register_shutdown_function Register a function for execution on shutdown. 

// serialize generates a storable representation of a value 

sleep Delay execution 

// uniqid Generate a unique id. 

// unpack unpack data from binary string 

// unserialize creates a PHP value from a stored representation 

usleep Delay execution in microseconds 

Prev Home Next 

mssql_select_db Ug connection_aborted 



PHP Manual 

Prev Next 



ignore_user_abort 

ignore_user_abort ~ Set whether a cHent disconnect should abort script execution 

Description 

int ignore_user_abort(int [setting]); 

This function sets whether a cHent disconnect should cause a script to be aborted. It will return the 
previous setting and can be called without an argument to not change the current setting and only 
return the current setting. See the Connection Handling section in the Features chapter for a 
complete description of connection handling in PHP. 

Prev Home Next 

get_browser Up iptcparse 



PHP Manual 

Prev Next 



get_browser 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

get_browser — Tells what the user's browser is capable of. 

Description 

object get_browser(string [user_agent]); 

get_browser() attempts to determine the capabilities of the user's browser. This is done by looking 
up the browser's information in the browscap.ini file. By default, the value of 
$HTTP_USER_AGENT is used; however, you can alter this (i.e., look up another browser's info) 
by passing the optional user_agent parameter to get_browser(). 

The information is returned in an object, which will contain various data elements representing, for 
instance, the browser's major and minor version numbers and ID string; true/false values for 
features such as frames, JavaScript, and cookies; and so forth. 

While brows cap . ini contains information on many browsers, it relies on user updates to keep 
the database current. The format of the file is fairly self-explanatory. 

The following example shows how one might list all available information retrieved about the 
user's browser. 

Example 1. get_browser() example 

<?php 

function list_array( $array ) { 

while ( list ( $key, $value ) = each ( $array ) ) { 
$str .= "<b>$key :</b> $value<br>\n" ; 

} 

return $str; 

} 

echo "$HTTP_USER_AGENT<hr>\n"; 

$browser = get_browser ( ) ; 

echo list_array( (array) $browser ); 

?> 



The output of the above script would look something like this: 



Mozilla/4.5 [en] (Xll; U; Linux 2.2.9 i586)<hr> 

<b>browser_name_pattern : </b> Mozilla/4\ . 5 . *<br> 

<b>parent : </b> Netscape 4.0<br> 

<b>platf orm: </b> Unknown<br> 

<b>ma jorver : </b> 4<br> 

<b>minorver : </b> 5<br> 

<b>browser : </b> Netscape<br> 

<b>version : </b> 4<br> 

<b>f rames : </b> l<br> 

<b>tables :</b> l<br> 

<b>cookies : </b> l<br> 

<b>backgroundsounds : </b> <br> 

<b>vbscript : </b> <br> 

<b> javascript : </b> l<br> 

<b> javaapplets : </b> l<br> 

<b>activexcontrols : </b> <br> 

<b>beta:</b> <br> 

<b>crawler : </b> <br> 

<b>authenticodeupdate : </b> <br> 

<b>msn:</b> <br> 

In order for this to work, your browscap configuration file setting must point to the correct location 

of the browscap . ini file. 

For more information (including locations from which you may obtain abrowscap.ini file), 
check the PHP FAQ at http://www.php.net/FAO.html . 

Note: browscap support was added to PHP in version 3.0b2. 

Prev Home Next 

function_exists Up ignore_user_abort 



PHP Manual 

Prev Next 



iptc parse 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



iptcparse ~ Parse a binary IPTC http://www.xe.net/iptc/ block into single tags. 

Description 

array iptcparse(string iptcblock); 

This function parses a binary IPTC block into its single tags. It returns an array using the tagmarker 
as an index and the value as the value. It returns false on error or if no IPTC data was found. See 
GetlmageSizeQ for a sample. 

Prev Home Next 

ignore_user_abort Up leak 



PHP Manual 

Prev Chapter 11. Control Structures Next 



switch 



The switch statement is similar to a series of IF statements on the same expression. In many 
occasions, you may want to compare the same variable (or expression) with many different values, 
and execute a different piece of code depending on which value it equals to. This is exactly what 
the switch statement is for. 

The following two examples are two different ways to write the same thing, one using a series of 
if statements, and the other using the switch statement: 

if ($i == 0) { 

print "i equals 0"; 

} 

if ($i == 1) { 

print "i equals 1"; 

} 

if ($i == 2) { 

print "i equals 2"; 
} 

switch ($i) { 
case : 

print "i equals 0"; 

break; 
case 1 : 

print "i equals 1"; 

break; 
case 2 : 

print "i equals 2"; 

break; 
} 

It is important to understand how the switch statement is executed in order to avoid mistakes. 
The switch statement executes line by line (actually, statement by statement). In the beginning, 
no code is executed. Only when a case statement is found with a value that matches the value of 
the switch expression does PHP begin to execute the statements. PHP continues to execute the 
statements until the end of the switch block, or the first time it sees a break statement. If you 
don't write a break statement at the end of a case's statement list, PHP will go on executing the 
statements of the following case. For example: 

switch ($i) { 
case : 

print "i equals 0"; 



case 1 : 

print "i equals 1"; 
case 2 : 

print "i equals 2"; 
} 

Here, if $i equals to 0, PHP would execute all of the print statements! If $i equals to 1, PHP would 
execute the last two print statements, and only if $i equals to 2, you'd get the 'expected' behavior 
and only 'i equals 2' would be displayed. So, it's important not to forget break statements (even 
though you may want to avoid supplying them on purpose under certain circumstances). 

In a switch statement, the condition is evaluated only once and the result is compared to each 
case statement. In an el self statement, the condition is evaluated again. If your condition is 
more complicated than a simple compare and/or is in a tight loop, a switch may be faster. 

The statement list for a case can also be empty, which simply passes control into the statement list 
for the next case. 

switch ($i) { 
case : 
case 1 : 
case 2 : 

print "i is less than 3 but not negative"; 
break; 
case 3 : 

print "i is 3"; 
} 

A special case is the default case. This case matches anything that wasn't matched by the other 
cases. For example: 

switch ($i) { 
case : 

print "i equals 0"; 

break; 
case 1 : 

print "i equals 1"; 

break; 
case 2 : 

print "i equals 2"; 

break; 
default : 

print "i is not equal to 0, 1 or 2"; 
} 

The case expression may be any expression that evaluates to a simple type, that is, integer or 
floating-point numbers and strings. Arrays or objects cannot be used here unless they are 
dereferenced to a simple type. 



The alternative syntax for control structures is supported with switches. For more information, see 
Alternative syntax for control structures . 

switch ( $i) : 
case : 

print "i equals 0"; 

break; 
case 1 : 

print "i equals 1"; 

break; 
case 2 : 

print "i equals 2"; 

break; 
default : 

print "i is not equal to 0, 1 or 2"; 
endswitch; 



Prev Home Next 

continue Ug requireQ 



PHP Manual 

Prev Next 



mail 




^lis function is not si 
PHP Lite edition. 
passible workaround not yet published. 

mail — send mail 

Description 

bool mail(string to, string subject, string message, string [additional_headers]); 

MailQ automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be 
specified by putting a comma between each address in t o. 
Example 1. Sending mail. 

mail ( "rasmus@lerdorf . on . ca" , "My Subject", "Line l\nLine 2\nLine 3"); 

If a fourth string argument is passed, this string is inserted at the end of the header. This is typically used to add extra headers. 
Multiple extra headers are separated with a newline. 

Example 2. Sending mail with extra headers. 

mail ( "nobody@aol . com" , "the subject", $message, 

"From: webmaster@$SERVER_NAME\nReply-To : webmaster@$SERVER_NAME\nX-Mailer : PHP/" 
. phpversion ( ) ) ; 

Prev Home Next 

Mail functions Up Mathematical functions 



PHP Manual 

Prev Next 



XXVIII. Mail functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



The mailQ function allows you to send mail. 
Table of Contents 

// mail send mail 

Prev Home Next 

ldap_error Up mail 



PHP Manual 

Prev Next 



XXIX. Mathematical functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



Introduction 



These math functions will only handle values within the range of the long and double types on your 
computer. If you need to handle bigger numbers, take a look at the arbitrary precision math 
functions. 



Math constants 



The following values are defined as constants in PHP by the math extension: 
Table 1. Math constants 



Constant 


Value 


Description 


M_PI 


3.14159265358979323846 


The value of f (pi) 



Table of Contents 

// Abs absolute value 

// Acos arc cosine 

// Asin arc sine 

// Atan arc tangent 

// Atan2 arc tangent of two variables 

// base_convert convert a number between arbitrary bases 

// BinDec binary to decimal 

// Ceil round fractions up 

//Cos cosine 

// DecBin decimal to binary 

// DecHex decimal to hexadecimal 



// DecOct decimal to octal 

//Exp e to the power of... 

// Floor round fractions down 

// getrandmax show largest possible random value 

// HexDec hexadecimal to decimal 

//Log natural logarithm 

//Log 10 base- 10 logarithm 

//max find highest value 

//min find lowest value 

// mt_rand generate a better random value 

// mt_srand seed the better random number generator 

// mt_getrandmax show largest possible random value 

// number_format format a number with grouped thousands 

// OctDec octal to decimal 

//pi get value of pi 

//pow exponential expression 

// rand generate a random value 

// round Rounds a float. 

// Sin sine 

// Sqrt square root 

// srand seed the random number generator 

//Tan tangent 

Prev Home Next 

mail Up Abs 



PHP Manual 

Prev Next 



system 

system ~ Execute an external program and display output 

Description 

string system(string command, int [return_var]); 

SystemQ is just like the C version of the function in that it executes the given command and 
outputs the result. If a variable is provided as the second argument, then the return status code of 
the executed command will be written to this variable. 

Note, that if you are going to allow data coming from user input to be passed to this function, then 
you should be using the EscapeShellCmdQ function to make sure that users cannot trick the 
system into executing arbitrary commands. 

The SystemQ call also tries to automatically flush the web server's output buffer after each line of 
output if PHP is running as a server module. 

Returns the last line of the command output on success, and false on failure. 

If you need to execute a command and have all the data from the command passed directly back 
without any interference, use the PassThruQ function. 

See also execQ , PassThruQ , popenQ , EscapeShellCmdQ , and the backtick operator . 

Prev Home Next 

passthru Ug GNU Recode functions 



PHP Manual 

Prev Next 



passthru 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



passtliru ~ Execute an external program and display raw output 

Description 

string passthr u (string command, int [retum_var] ) ; 

The passthruQ function is similar to the ExecQ function in that it executes a command. If the 
return_var argument is present, the return status of the Unix command will be placed here. 
This function should be used in place of ExecQ or SystemQ when the output from the Unix 
command is binary data which needs to be passed directly back to the browser. A common use for 
this is to execute something like the pbmplus utilities that can output an image stream directly. By 
setting the content- type to image/gif and then calling a pbmplus program to output a gif, you can 
create PHP scripts that output images directly. 

See also execQ , systemQ , popenQ , EscapeShellCmdQ , and the backtick operator . 

Prev Home Next 

exec Up system 



PHP Manual 

Prev Next 



XLVI. GNU Recode functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



This module contains an interface to the GNU Recode library, version 3.5. To be able to use the 
functions defined in this module you must compile you PHP interpreter using the —with-recode 
option. In order to do so, you must have GNU Recode 3.5 or higher installed on your system. 

The GNU Recode library converts files between various coded character sets and surface 
encodings. When this cannot be achieved exactly, it may get rid of the offending characters or fall 
back on approximations. The library recognises or produces nearly 150 different character sets and 
is able to convert files between almost any pair. Most RFC 1345 character sets are supported. 

Table of Contents 

// recode_string Recode a string according to a recode request. 
// recode_file Recode from file to file according to recode request. 

Prev Home Next 

system Up recode_string 



PHP Manual 

Prev Next 



escapeshellcmd 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

escapeshellcmd ~ escape shell metacharacters 

Description 

string e scapes he llcmd(string command); 

EscapeShellCmdQ escapes any characters in a string that might be used to trick a shell command 
into executing arbitrary commands. This function should be used to make sure that any data coming 
from user input is escaped before this data is passed to the execQ or systemQ functions, or to the 
backtick operator . A standard use would be: 

system (Escapeshellcmd ( $cmd) ) 

See also execQ , popenQ , systemQ , and the backtick operator . 

Prev Home Next 

Program Execution functions U^ exec 



PHP Manual 

Prev Next 



exec 

exec ~ Execute an external program 

Description 

string exec(string command, string [array], int [return_var]); 

execO executes the given command, however it does not output anything. It simply returns the last 
line from the result of the command. If you need to execute a command and have all the data from 
the command passed directly back without any interference, use the PassThruQ function. 

If the array argument is present, then the specified array will be filled with every line of output 
from the command. Note that if the array already contains some elements, exec() will append to the 
end of the array. If you do not want the function to append elements, call unsetQ on the array 
before passing it to exec(). 

If the return_var argument is present along with the array argument, then the return status of 
the executed command will be written to this variable. 

Note that if you are going to allow data coming from user input to be passed to this function, then 
you should be using EscapeShellCmdQ to make sure that users cannot trick the system into 
executing arbitrary commands. 

See also systemQ , PassThruQ , popenQ , EscapeShellCmdQ , and the backtick operator . 

Prev Home Next 

escapeshellcmd Up passthru 



PHP Manual 

Prev Next 



popen 

popen — open process file pointer 

Description 



int popen(string command, string mode); 

Opens a pipe to a process executed by forking tlie command given by command. 

Returns a file pointer identical to that returned by fopenQ , except that it is unidirectional (may only 
be used for reading or writing) and must be closed with pcloseQ . This pointer may be used with 
fgetsQ , fgetssQ , and fputsQ . 

If an error occurs, returns false. 

$fp = popen ( "/bin/Is", "r" ); 

See also pcloseQ . 

Prev Home Next 

pclose Up readfile 



PHP Manual 

Prev Chapter 10. Operators Next 



Execution Operators 



PHP supports one execution operator: backticks C^). Note that these are not single-quotes! PHP 
will attempt to execute the contents of the backticks as a shell command; the output will be returned 
(i.e., it won't simply be dumped to output; it can be assigned to a variable). 

$output = 'Is -al'; 

echo "<pre>$output</pre>" ; 

See also systemQ , passthruQ , execQ , popenQ , and escapeshellcmdQ . 

Prev Home Next 

Comparison Operators Up Incrementing/Decrementing 

Operators 



PHP Manual 

Prev Next 



XLV. Program Execution functions 

Table of Contents 

// escapeshellcmd escape shell metacharacters 

exec Execute an external program 

// passthru Execute an external program and display raw output 

system Execute an external program and display output 

Prev Home Next 

pg_tty Up escapeshellcmd 



PHP Manual 

Prev Next 



dl 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dl ~ load a PHP extension at runtime 

Description 

i n t d 1 ( string library) ; 

Loads the PHP extension defined in library. See also the extension_dir configuration directive. 

Prev Home Next 

Dynamic Loading functions Up Encryption functions 



PHP Manual 

Prev Next 



XIV. Dynamic Loading functions 



XX 111 lllV ~ 

geto I 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 

Table of Contents 

//dl load a PHP extension at runtime 

Prev Home Next 

rewinddir U^ dl 



PHP Manual 

Prev Next 



ifx_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_connect ~ Open Informix server connection 

Description 

int ifx_connect(string [database] , string [userid] , string [password] ); 

Returns an connection identifier on success, or FALSE on error. 

ifx_connect() estabhshes a connection to an Informix server. All of the arguments are optional, and 
if they're missing, defaults are taken from values supplied in configuration file (ifx.default_host for 
the host (Informix libraries will use INFORMIXSERVER environment value if not defined), 
ifx.default_user for user, ifx.default_password for the password (none if not defined). 

In case a second call is made to ifx_connect() with the same arguments, no new link will be 
established, but instead, the link identifier of the already opened link will be returned. 

The link to the server will be closed as soon as the execution of the script ends, unless it's closed 
earlier by explicitly calling ifx_close() . 

See also ifx_pconnect() , and ifx_close() . 
Example 1. Connect to a Informix database 

$conn_id = ifx_pconnect (mydb@ol_srvl, "imyself", "mypassword" ) ; 

Prev Home Next 

Informix functions Ug ifx_pconnect 



PHP Manual 

Prev Next 



XXV. Informix functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



The Informix driver for Online (ODS) 7.x, SE 7.x and Universal Server (lUS) 9.x is implemented 
in "functions/ifx.ec" and "functions/php3_ifx.h". ODS 7.x support is fairly complete, with full 
support for BYTE and TEXT columns. lUS 9.x support is partly finished: the new data types are 
there, but SLOB and CLOB support is still under construction. 

Configuration notes: 

Before you run the "configure" script, make sure that the "INFORMIXDIR" variable 
has been set. 

The configure script will autodetect the libraries and include directories, if you run 
"configure ~with_informix=yes". You can overide this detection by specifying 
"IFX_LIBDIR", "IFX_LIBS" and "IFXJNCDIR" in the environment. The configure 
script will also try to detect your Informix server version. It will set the 
"HAVE_IFX_IUS" conditional compilation variable if your Informix version >= 9.00. 

Some notes on the use of BLOBs (TEXT and BYTE columns): 

BLOBs are normally addressed by integer BLOB identifiers. Select queries return a 
"blob id" for every BYTE and TEXT column. You can get at the contents with 
"string_var = ifx_get_blob($blob_id);" if you choose to get the BLOBs in memory 
(with : "ifx_blobinfile(0);"). If you prefer to receive the content of BLOB columns in a 
file, use "ifx_blobinfile(l);", and "ifx_get_blob($blob_id);" will get you the filename. 
Use normal file I/O to get at the blob contents. 

For insert/update queries you must create these "blob id's" yourself with 
"ifx_create_blob(..);". You then plug the blob id's into an array, and replace the blob 
columns with a question mark (?) in the query string. For updates/inserts, you are 
responsible for setting the blob contents with ifx_update_blob(...). 

The behaviour of BLOB columns can be altered by configuration variables that also 
can be set at runtime : 

configuration variable : ifx.textasvarchar 

configuration variable : ifx.byteasvarchar 



runtime functions : 

ifx_textasvarchar(0) : use blob id's for select queries with TEXT columns 

ifx_byteasvarchar(0) : use blob id's for select queries with BYTE columns 

ifx_textasvarchar(l) : return TEXT columns as if they were VARCHAR columns, 
without the use of blob id's for select queries. 

ifx_byteasvarchar(l) : return BYTE columns as if they were VARCHAR columns, 
without the use of blob id's for select queries. 

configuration variable : ifx.blobinfile 

runtime function : 

ifx_blobinfile_mode(0) : return BYTE columns in memory, the blob id lets you get at 
the contents. 

ifx_blobinfile_mode(l) : return BYTE columns in a file, the blob id lets you get at the 
file name. 

If you set ifx_text/byteasvarchar to 1, you can use TEXT and BYTE columns in select 
queries just like normal (but rather long) VARCHAR fields. Since all strings are 
"counted" in PHP, this remains "binary safe". It is up to you to handle this correctly. 
The returned data can contain anything, you are responsible for the contents. 

If you set ifx_blobinfile to 1, use the file name returned by ifx_get_blob(..) to get at the 
blob contents. Note that in this case YOU ARE RESPONSIBLE FOR DELETING 
THE TEMPORARY FILES CREATED BY INFORMIX when fetching the row. 
Every new row fetched will create new temporary files for every BYTE column. 

The location of the temporary files can be influenced by the environment variable 
"blobdir", default is "." (the current directory). Something like : 
putenv(blobdir=tmpblob"); will ease the cleaning up of temp files accidentally left 
behind (their names all start with "bib"). 

Automatically trimming "char" (SQLCHAR and SQLNCHAR) data: 

This can be set with the configuration variable 

ifx.charasvarchar : if set to 1 trailing spaces will be automatically trimmed. 

NULL values: 

The configuration variable ifx.nullformat (and the runtime function ifx_nullformat() ) 
when set to true will return NULL columns as the string "NULL", when set to false 
they return the empty string. This allows you to discriminate between NULL columns 
and empty columns. 

Table of Contents 

// ifx_connect Open Informix server connection 

// ifx_pconnect Open persistent Informix connection 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



// 



fx close Close Informix connection 



fx_query Send Informix query 



fx_prepare Prepare an SQL-statement for execution 



fx_do Execute a previously prepared SQL- statement 



fx error Returns error code of last Informix call 



fx_errormsg Returns error message of last Informix call 



fx_affected_rows Get number of rows affected by a query 



fx_getsqlca Get the contents of sqlca.sqlerrd[0..5] after a query 



fx_fetch_row Get row as enumerated array 



fx_htmltbl_result Formats all rows of a query into a HTML table 



fx_fieldtypes List of Informix SQL fields 



fx_fieldproperties List of SQL fieldproperties 



fx_num_fields Returns the number of columns in the query 



fx_num_rows Count the rows already fetched a query 



fx_free_result Releases resources for the query 



fx_create_char Creates an char object 



fx_free_char Deletes the char object 



fx_update_char Updates the content of the char object 



fx_get_char Return the content of the char object 



fx_create_blob Creates an blob object 



fx_copy_blob Duplicates the given blob object 



fx_free_blob Deletes the blob object 



fx_get_blob Return the content of a blob object 



fx_update_blob Updates the content of the blob object 



fx_blobinfile_mode Set the default blob mode for all select queries 



fx textasvarchar Set the default text mode 



fx_byteasvarchar Set the default byte mode 



fx nullformat Sets the default return value on a fetch row 



fxus_create_slob Creates an slob object and opens it 



fx_free_slob Deletes the slob object 



fxus_close_slob Deletes the slob object 



fxus_open_slob Opens an slob object 



fxus_tell_slob Returns the current file or seek position 



fxus_seek_slob Sets the current file or seek position 



// ifxus_read_slob Reads nbytes of the slob object 
// ifxus_write_slob Writes a string into the slob object 



Prey Home Next 

imap_status Ug ifx_connect 



PHP Manual 

Prev Next 



ifx_pconnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_pconnect ~ Open persistent Informix connection 

Description 

int ifx_pconnect(string [database] , string [userid] , string [password] ); 
Returns: A positive Informix persistent Hnk identifier on success, or false on error 
ifx_pconnect() acts very much Hke ifx_connect() with two major differences. 

This function behaves exactly like ifx_connect() when PHP is not running as an Apache module. 
First, when connecting, the function would first try to find a (persistent) link that's already open 
with the same host, username and password. If one is found, an identifier for it will be returned 
instead of opening a new connection. 

Second, the connection to the SQL server will not be closed when the execution of the script ends. 
Instead, the link will remain open for future use ( ifx_close() will not close links established by 
ifx_pconnect()). 

This type of links is therefore called 'persistent'. 

See also: ifx_connect() . 

Prev Home Next 

ifx_connect Up ifx_close 



PHP Manual 

Prev Next 



ifx_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_close ~ Close Informix connection 

Description 

i n t if x_c lose (int [Hnk_identif ier] ) ; 

Returns: always true. 

ifx_close() closes the link to an Informix database that's associated with the specified link identifier. 
If the link identifier isn't specified, the last opened link is assumed. 

Note that this isn't usually necessary, as non-persistent open links are automatically closed at the 
end of the script's execution. 

ifx_close() will not close persistent links generated by ifx_pconnect() . 

See also: ifx_connect() , and ifx_pconnect() . 

Example 1. Closing a Informix connection 

$conn_id = ifx_connect (mydb@ol_srv, "itsme", "mypassword" ) ; 
. . . some queries and stuff . . . 
ifx_close ($conn_id) ; 



Prev Home Next 

ifx_pconnect Ug ifx_query 



PHP Manual 

Prev Next 



ifx blobinfile mode 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_blobinfile_mode ~ Set the default blob mode for all select queries 

Description 

void if x_blobinf ile_mode(int mode); 

Set the default blob mode for all select queries. Mode "0" means save Byte-Blobs in memory, and 
mode "1" means save Byte-Blobs in a file. 

Prev Home Next 

ifx_update_blob Up ifx_textasvarchar 



PHP Manual 

Prev Next 



ifx_update_blob 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_update_blob ~ Updates the content of the blob object 

Description 

ifx_update_blob(intbid, string content); 

Updates the content of the blob object for the given blob object bid. content is a string with 
new data. Returns FALSE on error otherwise TRUE. 

Prev Home Next 

ifx_get_blob Up ifx_blobinfile_mode 



PHP Manual 

Prev Next 



ifx_textasvarchar 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_textasvarchar ~ Set the default text mode 

Description 

void if x_textasvarchar(int mode); 



Sets the default text mode for all select-queries. Mode "0" will return a blob id, and mode "1" will 
return a varchar with text content. 

Prev Home Next 

ifx_blobinfile_mode Up ifx_byteasvarchar 



PHP Manual 

Prev Next 



ifx_byteasvarchar 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_byteasvarchar ~ Set the default byte mode 

Description 

void if x_byteasvarchar(int mode); 

Sets the default byte mode for all select-queries. Mode "0" will return a blob id, and mode "1" will 
return a varchar with text content. 

Prev Home Next 

ifx_textasvarchar Up ifx_nullformat 



PHP Manual 

Prev Next 



ifx nullformat 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_nullformat ~ Sets the default return value on a fetch row 

Description 

void if x_null format (int mode); 

Sets the default return value of a NULL-value on a fetch row. Mode "0" returns "", and mode "1" 
returns "NULL". 

Prev Home Next 

ifx_byteasvarchar Up ifxus_create_slob 



PHP Manual 

Prev Next 



ifxus create slob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_create_slob ~ Creates an slob object and opens it 

Description 

int if xus_create_slob(int mode); 

Creates an slob object and opens it. Modes: 1 = LO_RDONLY, 2 = LO_WRONLY, 4 = 
LO_APPEND, 8 = LO_RDWR, 16 = LO_BUFFER, 32 = LO_NOBUFFER -> or-mask. You can 
also use constants named IFX_LO_RDONLY, IFX_LO_WRONLY etc. Return FALSE on error 
otherwise the new slob object-id. 

Prev Home Next 

ifx_nullformat Ug ifx_free_slob 



PHP Manual 

Prev Next 



function_exists 

function_exists ~ Return true if the given function has been defined 

Description 

int f unction_exists(string function_name); 

Checks the Hst of defined functions for funct ion_name. Returns true if the given function name 
was found, false otherwise. 

Prev Home Next 

func_num_args U^ get_browser 



PHP Manual 

Prev Next 



odbc_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_connect ~ Connect to a datasource 

Description 



int odbc_connect(string dsn, string user, string password, int [cursor_type]); 

Returns an ODBC connection id or (false) on error. 

The connection id returned by this functions is needed by other ODBC functions. You can have 
multiple connections open at once. The optional fourth parameter sets the type of cursor to be used 
for this connection. This parameter is not normally needed, but can be useful for working around 
problems with some ODBC drivers. 

With some ODBC drivers, executing a complex stored procedure may fail with an error similar to: 
"Cannot open a cursor on a stored procedure that has anything other than a single select statement 
in it". Using SQL_CUR_USE_ODBC may avoid that error. Also, some drivers don't support the 
optional row_number parameter in odbc_fetch_row() . SQL_CUR_USE_ODBC might help in that 
case, too. 

The following constants are defined for cursortype: 

q SQL_CUR_USE_IF_NEEDED 

q SQL_CUR_USE_ODBC 

q SQL_CUR_USE_DRIVER 

q SQL_CUR_DEFAULT 
For persistent connections see odbc_pconnect() . 

Prev Home Next 

odbc_commit Up odbc_cursor 



PHP Manual 

Prev Next 



odbc commit 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_commit ~ Commit an ODBC transaction 

Description 

int odbc_commit(int connection_id); 

Returns: true on success, false on failure. All pending transactions on connect ion_id arc 
committed. 

Prev Home Next 

odbc_close_all Up odbc_connect 



PHP Manual 

Prev Next 



odbc_cursor 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_cursor ~ Get cursomame 

Description 

string odbc_cursor(int result_id); 

odbc_cursor will return a cursorname for the given result_id. 



Prev Home Next 

odbc_connect Up odbc_do 



PHP Manual 

Prev Next 



odbc_fetch_row 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_fetch_row ~ Fetch a row 

Description 

int odbc_f etch_row(int result_id, int [row_number]); 

If odbc_fetch_row() was succesful (there was a row), true is returned. If there are no more rows, 
false is returned. 

odbc_fetch_row() fetches a row of the data that was returned by odbc_do() / odbc_exec() . After 
odbc_fetch_row() is called, the fields of that row can be accessed with odbc_result() . 

If row_number is not specified, odbc_fetch_row() will try to fetch the next row in the result set. 
Calls to odbc_fetch_row() with and without row_number can be mixed. 

To step through the result more than once, you can call odbc_fetch_row() with row_number 1, 
and then continue doing odbc_fetch_row() without row_number to review the result. If a driver 
doesn't support fetching rows by number, the row_number parameter is ignored. 

Prev Home Next 

odbc_fetch_into Up odbc_field_name 



PHP Manual 

Prev Next 



odbc_pconnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_pconnect ~ Open a persistent database connection 

Description 

int odbc_p connect (string dsn, string user, string password, int [cursor_type]); 

Returns an ODBC connection id or (false) on error. This function is much Hke 
odbc_connect() , except that the connection is not really closed when the script has finished. Future 
requests for a connection with the same dsn, user, password combination (via odbc_connect() 
and odbc_pconnect()) can reuse the persistent connection. 

Note: Persistent connections have no effect if PHP is used as a CGI program. 

For information about the optional cursor_type parameter see the odbc_connect() function. For 
more information on persistent connections, refer to the PHP FAQ. 

Prev Home Next 

odbc_num_fields Ug odbc_prepare 



PHP Manual 

Prev Next 



XXXVII. ODBC functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



Table of Contents 

// odbc_autocommit Toggle autocommit behaviour 

// odbc_binmode handling of binary column data 

// odbc_close Close an ODBC connection 

// odbc_close_all Close all ODBC connections 

// odbc_commit Commit an ODBC transaction 

// odbc_connect Connect to a datasource 

// odbc_cursor Get cursorname 

// odbc_do synonym for odbc_exec() 

// odbc_exec Prepare and execute a SQL statement 

// odbc_execute execute a prepared statement 

// odbc_fetch_into Fetch one result row into array 

// odbc_fetch_row Fetch a row 

// odbc_field_name Get the columnname 

// odbc_field_type datatype of a field 

// odbc_field_len get the Length of a field 

// odbc_free_result free resources associated with a result 

// odbc_longreadlen handling of LONG columns 

// odbc_num_fields number of columns in a result 

// odbc_pconnect Open a persistent database connection 

// odbc_prepare Prepares a statement for execution 

// odbc_num_rows Number of rows in a result 

// odbc_result get result data 

// odbc result all Print result as HTML table 



// odbc_rollback Rollback a transaction 

// odbc_setoption Adjust ODBC settings. Returns false if an error occurs, otherwise true. 

Prev Home Next 

yp_err_string U^ odbc_autocommit 



PHP Manual 

Prev Next 



odbc num fields 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_num_fields ~ number of columns in a result 

Description 

int odbc_num_f ields(int result_id); 

odbc_num_fields() will return the number of fields (columns) in an ODBC result. This function 
will return -1 on error. The argument is a valid result identifier returned by odbc_exec() . 

Prev Home Next 

odbc_longreadlen Up odbc_pconnect 



PHP Manual 

Prev Next 



odbc_prepare 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_prepare ~ Prepares a statement for execution 

Description 

int odbc_prepare(int connection_id, string query_string); 

Returns false on error. 

Returns an ODBC result identifier if the SQL command was prepared successfully. The result 
identifier can be used later to execute the statement with odbc_execute() . 

Prev Home Next 

odbc_pconnect U^ odbc_num_rows 



PHP Manual 

Prev Next 



Chapter 6. Types 

Table of Contents 

Integers 

Floating point numbers 

Strings 

Arrays 

Objects 

Type juggling 

PHP supports the following types: 

q array 

q floating-point numbers 

q integer 

q object 

q string 

The type of a variable is usually not set by the programmer; rather, it is decided at runtime by PHP 
depending on the context in which that variable is used. 

If you would like to force a variable to be converted to a certain type, you may either cast the 
variable or use the settypeQ function on it. 

Note that a variable may behave in different manners in certain situations, depending on what type 
it is at the time. For more information, see the section on Type Juggling . 



Integers 



Integers can be specified using any of the following syntaxes: 

$a = 1234; # decimal number 

$a = -123; # a negative number 

$a = 0123; # octal number (equivalent to 83 decimal) 

$a = 0x12; # hexadecimal number (equivalent to 18 decimal) 



Prev Home Next 



Comments Ug Floating point numbers 



PHP Manual 

Prev Next 



Chapter 7. Variables 



Table of Contents 

Basics 

Predefined variables 
Variable scope 
Variable variables 
Variables from outside PHP 

Basics 

Variables in PHP are represented by a dollar sign followed by the name of the variable. The 
variable name is case-sensitive. 

$var = "Bob"; 
$Var = "Joe"; 
echo "$var, $Var"; // outputs "Bob, Joe" 

In PHP3, variables are always assigned by value. That is to say, when you assign an expression to a 
variable, the entire value of the original expression is copied into the destination variable. This 
means, for instance, that after assigning one variable's value to another, changing one of those 
variables will have no effect on the other. For more information on this kind of assignment, see 
Expressions . 

PHP4 offers another way to assign values to variables: assign by reference. This means that the 
new variable simply references (in other words, "becomes an alias for" or "points to") the original 
variable. Changes to the new variable affect the original, and vice versa. This also means that no 
copying is performed; thus, the assignment happens more quickly. However, any speedup will 
likely be noticed only in tight loops or when assigning large arrays or objects. 

To assign by reference, simply prepend an ampersand (&) to the beginning of the variable which is 
being assigned (the source variable). For instance, the following code snippet outputs 'My name is 
Bob' twice: 

<?php 

$foo = 'Bob'; // Assign the value 'Bob' to $foo 

$bar = &$foo; // Reference $foo via $bar. 

$bar = "My name is $bar"; // Alter $bar. . . 

echo $foo; // $foo is altered too. 

echo $bar; 



?> 



One important thing to note is that only named variables may be assigned by reference. 

<?php 

$foo = 25; 

$bar = &$foo; // This is a valid assignment. 

$bar = & (24 * 7); // Invalid; references an unnamed expression 

function test() { 

return 25; 
} 

$bar = &test(); // Invalid. 
?> 



Prev Home Next 

Type juggling U^ Predefined variables 



PHP Manual 

Prev Next 



Chapter 8. Constants 



PHP defines several constants and provides a mechanism for defining more at run-time. Constants 
are much Hke variables, save for the two facts that constants must be defined using the defineQ 
function, and that they cannot later be redefined to another value. 

The predefined constants (always available) are: 
__FILE_ 

The name of the script file presently being parsed. If used within a file which has been 
included or required, then the name of the included file is given, and not the name of the 
parent file. 

__LINE__ 

The number of the line within the current script file which is being parsed. If used within a 
file which has been included or required, then the position within the included file is given. 

PHP_VERSION 

The string representation of the version of the PHP parser presently in use; e.g. '3.0.8-dev'. 
PHP_OS 

The name of the operating system on which the PHP parser is executing; e.g. 'Linux'. 
TRUE 

A true value. 
FALSE 

A false value. 
E_ERROR 

Denotes an error other than a parsing error from which recovery is not possible. 
E_WARNING 

Denotes a condition where PHP knows something is wrong, but will continue anyway; these 
can be caught by the script itself. An example would be an invalid regexp in eregQ . 

E_PARSE 

The parser choked on invalid syntax in the script file. Recovery is not possible. 
E_NOTICE 

Something happened which may or may not be an error. Execution continues. Examples 
include using an unquoted string as a hash index, or accessing a variable which has not been 
set. 



The E_* constants are typically used with the error_reporting() function for setting the error 
reporting level. 

You can define additional constants using the defineQ function. 

Note that these are constants, not C-style macros; only valid scalar data may be represented by a 
constant. 

Example 8-1. Defining Constants 

<?php 

define ("CONSTANT", "Hello world."); 

echo CONSTANT; // outputs "Hello world." 

?> 

Example 8-2. Using __FILE_ and __LINE__ 

<?php 

function report_error ( $f lie, $line, $message) { 

echo "An error occured in $file on line $line: $message."; 
} 

report_error ( FILE , LINE , "Something went wrong!"); 

?> 



Prev Home Next 

Variables from outside PHP Ug Expressions 



PHP Manual 

Prev Next 



Chapter 9. Expressions 



Expressions are the most important building stones of PHP. In PHP, almost anything you write is an expression. 
The simplest yet most accurate way to define an expression is "anything that has a value". 

The most basic forms of expressions are constants and variables. When you type "$a = 5", you're assigning '5' 
into $a. '5', obviously, has the value 5, or in other words '5' is an expression with the value of 5 (in this case, '5' 
is an integer constant). 

After this assignment, you'd expect $a's value to be 5 as well, so if you wrote $b = $a, you'd expect it to behave 
just as if you wrote $b = 5. In other words, $a is an expression with the value of 5 as well. If everything works 
right, this is exactly what will happen. 

Slightly more complex examples for expressions are functions. For instance, consider the following function: 

function foo () { 

return 5; 
} 

Assuming you're familiar with the concept of functions (if you're not, take a look at the chapter about 
functions), you'd assume that typing $c = foo ( ) is essentially just like writing $c = 5, and you're right. 
Functions are expressions with the value of their return value. Since foo() returns 5, the value of the expression 
'fooO' is 5. Usually functions don't just return a static value but compute something. 

Of course, values in PHP don't have to be integers, and very often they aren't. PHP supports three scalar value 
types: integer values, floating point values and string values (scalar values are values that you can't 'break' into 
smaller pieces, unlike arrays, for instance). PHP also supports two composite (non-scalar) types: arrays and 
objects. Each of these value types can be assigned into variables or returned from functions. 

So far, users of PHP/FI 2 shouldn't feel any change. However, PHP takes expressions much further, in the same 
way many other languages do. PHP is an expression-oriented language, in the sense that almost everything is an 
expression. Consider the example we've already dealt with, '$a = 5'. It's easy to see that there are two values 
involved here, the value of the integer constant '5', and the value of $a which is being updated to 5 as well. But 
the truth is that there's one additional value involved here, and that's the value of the assignment itself. The 
assignment itself evaluates to the assigned value, in this case 5. In practice, it means that '$a = 5', regardless of 
what it does, is an expression with the value 5. Thus, writing something like '$b = ($a = 5)' is like writing '$a = 
5; $b = 5;' (a semicolon marks the end of a statement). Since assignments are parsed in a right to left order, you 
can also write '$b = $a = 5'. 

Another good example of expression orientation is pre- and post-increment and decrement. Users of PHP/FI 2 
and many other languages may be familiar with the notation of variable++ and variable—. These are increment 
and decrement operators. In PHP/FI 2, the statement '$a++' has no value (is not an expression), and thus you 
can't assign it or use it in any way. PHP enhances the increment/decrement capabilities by making these 
expressions as well, like in C. In PHP, like in C, there are two types of increment - pre-increment and 
post-increment. Both pre-increment and post- increment essentially increment the variable, and the effect on the 
variable is idential. The difference is with the value of the increment expression. Pre-increment, which is 
written '++$variable', evaluates to the incremented value (PHP increments the variable before reading its value, 
thus the name 'pre-increment'). Post-increment, which is written '$variable++' evaluates to the original value of 
$variable, before it was incremented (PHP increments the variable after reading its value, thus the name 
'post-increment'). 



A very common type of expressions are comparison expressions. These expressions evaluate to either or 1, 
meaning FALSE or TRUE (respectively). PHP supports > (bigger than), >= (bigger than or equal to), == 
(equal), != (not equal), < (smaller than) and <= (smaller than or equal to). These expressions are most 
commonly used inside conditional execution, such as if statements. 

The last example of expressions we'll deal with here is combined operator-assignment expressions. You already 
know that if you want to increment $a by 1 , you can simply write '$a++' or '++$a'. But what if you want to add 
more than one to it, for instance 3? You could write '$a++' multiple times, but this is obviously not a very 
efficient or comfortable way. A much more common practice is to write '$a = $a + 3'. '$a + 3' evaluates to the 
value of $a plus 3, and is assigned back into $a, which results in incrementing $a by 3. In PHP, as in several 
other languages like C, you can write this in a shorter way, which with time would become clearer and quicker 
to understand as well. Adding 3 to the current value of $a can be written '$a += 3'. This means exactly "take the 
value of $a, add 3 to it, and assign it back into $a". In addition to being shorter and clearer, this also results in 
faster execution. The value of '$a += 3', like the value of a regular assignment, is the assigned value. Notice that 
it is NOT 3, but the combined value of $a plus 3 (this is the value that's assigned into $a). Any two-place 
operator can be used in this operator-assignment mode, for example '$a -= 5' (subtract 5 from the value of $a), 
'$b *= 7' (multiply the value of $b by 7), etc. 

There is one more expression that may seem odd if you haven't seen it in other languages, the ternary 
conditional operator: 

$first ? $second : $third 

If the value of the first subexpression is true (non-zero), then it the second subexpression is evaluated, and that 
is the result of the conditional expression. Otherwise, the third subexpression is evaluated, and that is the value. 

The following example should help you understand pre- and post-increment and expressions in general a bit 
better: 



function double ($i) 


{ 


return $i*2; 
} 
$b = $a = 5; 




/* 


$c = $a++; 


/* 



assign the value five into the variable $a and $b */ 
post-increment, assign original value of $a 
(5) to $c */ 
$e = $d = ++$b; /* pre-increment , assign the incremented value of 

$b (6) to $d and $e */ 

/* at this point, both $d and $e are equal to 6 */ 

$f = double ($d++) ; /* assign twice the value of $d before 

the increment, 2*6 = 12 to $f */ 
$g = double ( + + $e) ; /* assign twice the value of $e after 

the increment, 2*7 = 14 to $g */ 
$h = $g += 10; /* first, $g is incremented by 10 and ends with the 

value of 24. the value of the assignment (24) is 

then assigned into $h, and $h ends with the value 

of 24 as well. */ 

In the beginning of the chapter we said that we'll be describing the various statement types, and as promised, 
expressions can be statements. However, not every expression is a statement. In this case, a statement has the 
form of 'expr' ';' that is, an expression followed by a semicolon. In '$b=$a=5;', $a=5 is a valid expression, but it's 
not a statement by itself. '$b=$a=5;' however is a valid statement. 

One last thing worth mentioning is the truth value of expressions. In many events, mainly in conditional 
execution and loops, you're not interested in the specific value of the expression, but only care about whether it 
means TRUE or FALSE (PHP doesn't have a dedicated boolean type). The truth value of expressions in PHP is 
calculated in a similar way to perl. Any numeric non-zero numeric value is TRUE, zero is FALSE. Be sure to 



note that negative values are non-zero and are thus considered TRUE! The empty string and the string "0" are 
FALSE; all other strings are TRUE. With non-scalar values (arrays and objects) - if the value contains no 
elements it's considered FALSE, otherwise it's considered TRUE. 

PHP provides a full and powerful implementation of expressions, and documenting it entirely goes beyond the 
scope of this manual. The above examples should give you a good idea about what expressions are and how you 
can construct useful expressions. Throughout the rest of this manual we'll write expr to indicate any valid PHP 
expression. 

Prev Home Next 

Constants Ug Operators 



PHP Manual 



Prev 



Next 



Chapter 1 0. Operators 

Table of Contents 

Arithmetic Operators 

Assignment Operators 

Bitwise Operators 

Comparison Operators 

Execution Operators 

Incrementing/Decrementing Operators 

Logical Operators 

Operator Precedence 

String Operators 

Arithmetic Operators 

Remember basic aritlimetic from scliool? Tliese work just like those. 
Table 10-1. Arithmetic Operators 



example 


name 


result 


$a + $b 


Addition 


Sum of $a and $b. 


$a-$b 


Subtraction 


Difference of $a and $b. 


$a*$b 


Multiplication 


Product of $a and $b. 


$a/$b 


Division 


Quotient of $a and $b. 


$a % $b 


Modulus 


Remainder of $a divided by $b. 



Prev 
Expressions 



Home 
Up 



Next 
Assignment Operators 



PHP Manual 

Prev Next 



Chapter 13. Classes and Objects 

Table of Contents 

class 

class 

A class is a collection of variables and functions working with these variables. A class is defined 
using the following syntax: 

<?php 

class Cart { 

var $items; // Items in our shopping cart 

// Add $num articles of $artnr to the cart 

function add_item ($artnr, $num) { 

$this->items [$artnr ] += $num; 
} 

// Take $num articles of $artnr out of the cart 

function remove_item ($artnr, $num) { 
if ( $this->items [$artnr ] > $num) { 
$this->items [$artnr ] -= $num; 
return true; 
} else { 

return false; 
} 
} 
} 
?> 



This defines a class named Cart that consists of an associative array of articles in the cart and two 
functions to add and remove items from this cart. 

Classes are types, that is, they are blueprints for actual variables. You have to create a variable of 
the desired type with the new operator. 

$cart = new Cart; 
$cart->add_item("10", 1); 



This creates an object $cart of the class Cart. The function add_item() of that object is being called 
to add 1 item of article number 10 to the cart. 

Classes can be extensions of other classes. The extended or derived class has all variables and 
functions of the base class and what you add in the extended definition. This is done using the 
extends keyword. Multiple inheritance is not supported. 

class Named_Cart extends Cart { 
var $owner; 

function set_owner ($name) { 

$this->owner = $name; 
} 



This defines a class Named_Cart that has all variables and functions of Cart plus an additional 
variable $owner and an additional function set_owner(). You create a named cart the usual way and 
can now set and get the carts owner. You can still use normal cart functions on named carts: 

$ncart = new Named_Cart; // Create a named cart 

$ncart->set_owner ("kris"); // Name that cart 

print $ncart->owner; // print the cart owners name 

$ncart->add_item ("10", 1); // (inherited functionality from cart) 

Within functions of a class the variable $this means this object. You have to use $this->something 
to access any variable or function named something within your current object. 

Constructors are functions in a class that are automatically called when you create a new instance of 
a class. A function becomes a constructor when it has the same name as the class. 

class Auto_Cart extends Cart { 

function Auto_Cart () { 

$this->add_item ("10", 1); 

} 
} 

This defines a class Auto_Cart that is a Cart plus a constructor which initializes the cart with one 
item of article number "10" each time a new Auto_Cart is being made with "new". Constructors can 
also take arguments and these arguments can be optional, which makes them much more useful. 

class Constructor_Cart extends Cart { 

function Constructor_Cart ($item = "10", $num = 1) { 
$this->add_item ($item, $num) ; 

} 
} 

// Shop the same old boring stuff. 
$def ault_cart = new Constructor_Cart ; 



// Shop for real... 

$dif f erent_cart = new Constructor_Cart ("20", 17); 



Caution 



For derived classes, the constructor of the parent class is not automatically called when the 
derived class's constructor is called. 



Prev Home Next 

Variable functions Ug Features 



PHP Manual 

Prev Next 



mcrypt_get_cipher_name 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcrypt_get_cipher_name ~ Get the name of the specified cipher 

Description 

string mcrypt_get_cipher_name(int cipher); 

mcrypt_get_dpher_name() is used to get the name of the specified cipher. 

mcrypt_get_cipher_name() takes the cipher number as an argument and returns the name of the 
cipher or false, if the cipher does not exist. 

Example 1. mcrypt_get_cipher_name example 

<?php 

$cipher = MCRYPT_TripleDES; 

print mcrypt_get_cipher_name ($ cipher ) ; 
?> 

The above example will produce: 

TripleDES 

Prev Home Next 

Encryption functions Ug mcrypt_get_block_size 



PHP Manual 

Prev Next 



mcrypt_cfb 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_cfb ~ Encrypt/decrypt data in CFB mode 

Description 

int mcrypt_cf b(int cipher, string key, string data, int mode, string iv); 

mcrypt_cfb() encrypts or decrypts (depending on mode) the data with cipher and icey in CFB 
cipher mode and returns the resulting string. 

cipher is one of the MCRYPT_ciphername constants. 

key is the key supphed to the algorithm. It must be kept secret. 

data is the data which shall be encrypted/decrypted. 

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. 

i V is the initialization vector. 

See also: mcrypt_cbc() , mcrypt_ecb() , mcrypt_ofb() 

Prev Home Next 

mcrypt_cbc IJ£ mcrypt_ecb 



PHP Manual 

Prev Next 



mcrypt_cbc 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_cbc ~ Encrypt/decrypt data in CBC mode 

Description 

int mcrypt_cbc(int cipher, string key, string data, int mode, string [iv]); 

mcrypt_cbc() encrypts or decrypts (depending on mode) the data with cipher and key in 
CBC cipher mode and returns the resulting string. 

cipher is one of the MCRYPT_ciphemame constants. 

key is the key supphed to the algorithm. It must be kept secret. 

data is the data which shall be encrypted/decrypted. 

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. 

i V is the optional initialization vector. 

See also: mcrypt_cfb() , mcrypt_ecb() , mcrypt_ofb() 

Prev Home Next 

mcrypt_create_iv IJ£ mcrypt_cfb 



PHP Manual 

Prev Next 



mcrypt_ecb 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_ecb ~ Encrypt/decrypt data in ECB mode 

Description 

int mcrypt_ecb(int cipher, string key, string data, int mode); 

mcrypt_ecb() encrypts or decrypts (depending on mode) the data with cipher and key in ECB 
cipher mode and returns the resulting string. 

cipher is one of the MCRYPT_ciphername constants. 

key is the key supphed to the algorithm. It must be kept secret. 

data is the data which shall be encrypted/decrypted. 

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. 

See also: mcrypt_cbc() , mcrypt_cfb() , mcrypt_ofb() 

Prev Home Next 

mcrypt_cfb Up mcrypt_ofb 



PHP Manual 

Prev Next 



mcrypt_ofb 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_ofb ~ Encrypt/decrypt data in OFB mode 

Description 

int mcrypt_of b(int cipher, string key, string data, int mode, string iv); 

mcrypt_ofb() encrypts or decrypts (depending on mode) the data with cipher and key in OFB 
cipher mode and returns the resulting string. 

cipher is one of the MCRYPT_ciphername constants. 

key is the key supphed to the algorithm. It must be kept secret. 

data is the data which shall be encrypted/decrypted. 

mode is MCRYPT_ENCRYPT or MCRYPT_DECRYPT. 

i V is the initialization vector. 

See also: mcrypt_cbc() , mcrypt_cfb() , mcrypt_ecb() 

Prev Home Next 

mcrypt_ecb IJ£ filePro functions 



PHP Manual 

Prev Next 



mcrypt_get_block_size 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_get_block_size ~ Get the block size of the specified cipher 

Description 

int mcrypt_get_block_size(int cipher); 

mcrypt_get_block_size() is used to get the size of a block of the specified cipher. 
mcrypt_get_block_size() takes one argument, the cipher and returns the size in bytes. 
See also: mcrypt_get_key_size() 

Prev Home Next 

mcrypt_get_cipher_name Up mcrypt_get_key_size 



PHP Manual 

Prev Next 



mcrypt_get_key_size 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_get_key_size ~ Get the key size of the specified cipher 

Description 

int mcrypt_get_key_size(int cipher); 

mcrypt_get_key_size() is used to get the size of a key of the specified cipher. 
mcrypt_get_key_size() takes one argument, the cipher and returns the size in bytes. 
See also: mcrypt_get_block_size() 

Prev Home Next 

mcrypt_get_block_size Up mcrypt_create_iv 



PHP Manual 

Prev Next 



mcrypt_create_iv 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcrypt_create_iv ~ Create an initiahzation vector (IV) from a random source 

Description 

string mcrypt_create_iv(int size, int source); 

mcrypt_create_iv() is used to create an IV. 

mcrypt_create_iv() takes two arguments, size determines the size of the IV, source specifies 
the source of the IV. 

The source can be MCRYPT_RAND (system random number generator), 
MCRYPT_DEV_RANDOM (read data from /dev/random) and MCRYPT_DEV_URANDOM 
(read data from /dev/urandom). If you use MCRYPT_RAND, make sure to call srand() before to 
initialize the random number generator. 

Example 1. mcrypt_create_iv example 

<?php 

$cipher = MCRYPT_TripleDES; 

$block_size = mcrypt_get_block_size ( $cipher ) ; 

$iv = mcrypt_create_iv ($block_size, MCRYPT_DEV_RANDOM) ; 

?> 



Prev Home Next 

mcrypt_get_key_size Up mcrypt_cbc 



PHP Manual 

Prev Next 



IV. Function Reference 

These manual-pages have been adapted to the 

PHP Lite Edition. 

The modules/functions not supported by PHP 

Lite are marked with 7/' 

and the manual-page for that module/function has 

a note stating that 

it is not supported. 

If a replacement for a function has been 

submitted this is noted with a 

link to a separate page. 

Table of Contents 

L // Adabas D functions 

IL // Apache-specific functions 

in. // Arbitrary precision mathematics functions 

IV. Array functions 

V. // Aspell functions 

VI. // Calendar functions 

VII. // ClibPDF functions 

VIII. // Compression functions 

IX. // Database (dbm-style) abstraction layer functions 

X. Date and Time functions 
XL // dBase functions 

XII. // dbm functions 

XIII. Directory functions 

XIV. // Dynamic Loading functions 

XV. // Encryption functions 

XVI. // filePro functions 

XVII. Filesystem functions 

XVIII. // Forms Data Format functions 

XIX. FTP functions 

XX. // Hash functions 

XXI. HTTP functions 



XXII. // Hyperwave functions 

XXIII. // Image functions 

XXIV. // IMAP functions 

XXV. // Informix functions 

XXVI. // InterBase functions 

XXVII. // LDAP functions 

XXVIII. // Mail functions 

XXIX. // Mathematical functions 

XXX. // MCAL functions 

XXXI. // Microsoft SQL Server functions 

XXXII. Miscellaneous functions 

XXXIII. // mSQL functions 

XXXIV. // MySQL functions 

XXXV. Network functions 

XXXVI. // NIS functions 

XXXVII. // ODBC functions 

XXXVIII. // Oracle functions 

XXXIX. // Oracle 8 functions 
XL. // PDF functions 

XLI. // Perl-compatible Regular Expression functions 

XLII. PHP options & information 

XLIII. // POSIX functions 

XLIV. // PostgreSQL functions 

XLV. Program Execution functions 

XL VI. // GNU Recode functions 

XL VII. // Regular expression functions 

XL VIII. // Semaphore and shared memory functions 

XLIX. // Session handling functions 

L. // SNMP functions 

LI. // Solid functions 

LII. String functions 

LIII. // Sybase functions 

LIV. URL functions 

LV. Variable functions 



LVI. // Vmailmgr functions 
LVII. // WDDX functions 
LVIII. // XML parser functions 



Prev Home Next 

Persistent database connections Adabas D functions 



PHP Manual 

Prev Next 



sql_regcase 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



sql_regcase ~ make regular expression for case insensitive match 

Description 

string sql_regcase(string string); 

Returns a vahd regular expression which will match string, ignoring case. This expression is 
string with each character converted to a bracket expression; this bracket expression contains 
that character's uppercase and lowercase form if applicable, otherwise it contains the original 
character twice. 

Example 1. sql_regcase() example 

echo sql_regcase ( "Foo bar" ) ; 
prints 
[Ff ] [Oo] [Oo] [ ] [Bb] [Aa] [Rr] 



This can be used to achieve case insensitive pattern matching in products which support only case 
sensitive regular expressions. 

Prev Home Next 

split Ug Semaphore and shared memory 

functions 



PHP Manual 

Prev Next 



sem_get 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



sem_get ~ get a semaphore id 

Description 

int sem_get(int key, int [max_acquire] , int [perm] ); 

Returns: A positive semaphore identifier on success, or false on error. 

sem_get() returns an id that can be used to access the System V semaphore with the given key. The 
semaphore is created if necessary using the permission bits specified in perm (defaults to 0666). 
The number of processes that can acquire the semaphore simultaneously is set to max_acquire 
(defaults to 1). Actually this value is set only if the process finds it is the only process currently 
attached to the semaphore. 

A second call to sem_get() for the same key will return a different semaphore identifier, but both 
identifiers access the same underlying semaphore. 

See also: sem_acquire() and sem_release() . 

Prev Home Next 

Semaphore and shared memory Up sem_acquire 

functions 



PHP Manual 

Prev Next 



sem_acquire 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

sem_acquire ~ acquire a semaphore 

Description 

int sem_acquire(int sem_identifier); 

Returns: true on success, false on error 

sem_acquire() blocks (if necessary) until the semaphore can be acquired. A process attempting to 
acquire a semaphore which it has already acquired will block forever if acquiring the semaphore 
would cause its max_acquire value to be exceeded. 

After processing a request, any semaphores acquired by the process but not explicitly released will 
be released automatically and a warning will be generated. 

See also: sem_get() and sem_release() . 

Prev Home Next 

sem_get Up sem_release 



PHP Manual 

Prev Next 



sem release 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



sem_release ~ release a semaphore 

Description 

int sem_release(int sem_identifier); 

Returns: true on success, false on error 

sem_release() releases the semaphore if it is currently acquired by the calling process, otherwise a 
warning is generated. 

After releasing the semaphore, sem_acquire() may be called to re-acquire it. 
See also: sem_get() and sem_acquire() . 

Prev Home Next 

sem_acquire U^ shm_attach 



PHP Manual 

Prev Next 



shm_attach 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

shm_attach ~ Creates or open a shared memory segment 

Description 

int shm_attach(int key, int [memsize], int [perm]); 

shm_attach() returns an id that that can be used to access the System V shared memory with the 
given key, the first call creates the shared memory segment with mem_size (default: 
sysvshm.init_mem in the configuration file , otherwise 10000 bytes) and the optional perm-bits 
(default: 0666). 

A second call to shm_attach() for the same key will return a different shared memory identifier, 
but both identifiers access the same underlying shared memory, memsize and perm will be 
ignored. 

Prev Home Next 

sem_release Up shm_detach 



PHP Manual 

Prev Next 



shm detach 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

shm_detach ~ Disconnects from shared memory segment 

Description 

int shm_detach(int shm_identifier); 

shm_detach() disconnects from the shared memory given by the shm_identifier created by 
shm_attach() . Remember, that shared memory still exist in the Unix system and the data is still 
present. 

Prev Home Next 

shm_attach Up shm_remove 



PHP Manual 

Prev Next 



shm_remove 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

shm_remove ~ Removes shared memory from Unix systems 

Description 

int shm_remove(int shm_identifier); 

Removes shared memory from Unix systems. All data will be destroyed. 

Prev Home Next 

shm_detach Up shm_put_var 



PHP Manual 

Prev Next 



shm_put_var 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



shm_put_var ~ Inserts or updates a variable in shared memory 

Description 

int shm_put_var(int shm_identifier, int variable_key, mixed variable); 

Inserts or updates a variable with a given variable_key. All variable-types (double, int, 
string, array) are supported. 

Prev Home Next 

shm_remove Up shm_get_var 



PHP Manual 

Prev Next 



shm_get_var 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

shm_get_var ~ Returns a variable from shared memory 

Description 

mixed shm_get_var(int id, int variable_key); 

shm_get_var() returns the variable with a given variable_key. The variable is still present in 
the shared memory. 

Prev Home Next 

shm_put_var Up shm_remove_var 



PHP Manual 

Prev Next 



shm_remove_var 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

shm_remove_var ~ Removes a variable from shared memory 

Description 

int shm_remove_var(int id, int variable_key); 

Removes a variable with a given variable_key and frees the occupied memory. 

Prev Home Next 

shm_get_var Up Session handling functions 



PHP Manual 

Prev Next 



wddx deserialize 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

wddx_deseriaHze ~ DeseriaHzes a WDDX packet 

Description 

mixed wddx_deserialize(string packet); 

wddx_deserialized() takes a. packet string and deseriahzes it. It returns the result which can be 
string, number, or array. Note that structures are deseriahzed into associative arrays. 

Prev Home Next 

wddx_add_vars Up XML parser functions 



PHP Manual 

Prev Next 



xml_parser_create 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_parser_create ~ create an XML parser 

Description 

int xml_parser_create(string [encoding] ); 
encoding (optional) 

Which character encoding the parser should use. The following character encodings are 
supported: 

IS 0-8859-1 (default) 

US-ASCII 

UTF-8 

This function creates an XML parser and returns a handle for use by other XML functions. Returns 
false on failure. 

Prev Home Next 

XML parser functions Up xml_set_object 



PHP Manual 



Prev 



Next 



xml_parser_set_option 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



edJ 



xml_parser_set_option ~ set options in an XML parser 



Description 



int xml_parser_set_option(int parser, int option, mixed value); 

parser 

A reference to the XML parser to set an option in. 

option 

Which option to set. See below. 

value 

The option's new value. 

This function returns false if parser does not refer to a valid parser, or if the option could not be 
set. Else the option is set and true is returned. 

The following options are available: 

Table 1. XML parser options 



Option constant 


Data type 


Description 


XML OPTION CASE FOLDING 

1 


integer 


Controls whether case-folding is enabled for 
this XML parser. Enabled by default. 


XML_OPTION_TARGET_ENCODING 


string 


Sets which target encoding to use in this 
XML parser. By default, it is set to the same 
as the source encoding used by 
xml_parser_create(). Supported target 


encodings are ISO-8859-1, US-ASCII 
andUTF-8. 



Prev 
xml_parser_free 



Home 



Next 
xml_parser_get_option 



PHP Manual 

Prev Next 



xml set element handler 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_set_element_handler ~ set up start and end element handlers 

Description 

int xml_set_element_handler (int parser, string startElementHandler , string 
endElementHandler ); 

Sets the element handler functions for the XML parser parser. startElementHandler and 
endElementHandler are strings containing the names of functions that must exist when 
xml_parse() is called for parser. 

The function named by startElementHandler -must accept three parameters: 
startElementHandler(mt parser, string name, string attribs); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

name 

The second parameter, name, contains the name of the element for which this handler is 
called. If case-folding is in effect for this parser, the element name will be in uppercase 
letters. 

attribs 

The third parameter, attribs, contains an associative array with the element's attributes (if 
any). The keys of this array are the attribute names, the values are the attribute values. 
Attribute names are case-folded on the same criteria as element names. Attribute values are 
not case-folded. 

The original order of the attributes can be retrieved by walking through attribs the 
normal way, using eachQ . The first key in the array was the first attribute, and so on. 

The function named by endElementHandler must accept two parameters: 

endEl emeu tHaiidier(int parser, string name); 

parser 



The first parameter, parser, is a reference to the XML parser calhng the handler. 

name 

The second parameter, name, contains the name of the element for which this handler is 
called. If case-folding is in effect for this parser, the element name will be in uppercase 
letters. 

If a handler function is set to an empty string, or false, the handler in question is disabled. 

True is returned if the handlers are set up, false if parser is not a parser. 

There is currently no support for object/method handlers. 

Prev Home Next 

xml_set_object Ug xml_set_character_data_handler 



PHP Manual 

Prev Next 



xml set character data handler 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_set_character_data_handler ~ set up character data handler 

Description 

int xml_set_character_data_handler (int parser, string handler); 

Sets the character data handler function for the XML parser parser, handler is a string 
containing the name of a function that must exist when xml_parse() is called for parser. 

The function named by handler must accept two parameters: 
handler(mt parser, string data); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

data 

The second parameter, data, contains the character data as a string. 
If a handler function is set to an empty string, or false, the handler in question is disabled. 
True is returned if the handler is set up, false if parser is not a parser. 
There is currently no support for object/method handlers. 

Prev Home Next 

xml_set_element_handler Up xml_set_processing_instruction_handler 



PHP Manual 

Prev Next 



xml_set_processing_instruction_handler 



This function is not supported in t 

PHP Lite edition. 

Possible workaround not vet published 



m 

ished.~ 



xml_set_processing_instruction_handler — Set up processing instruction (PI) handler 

Description 

int xml_set_processing_instruction_handler (int parser, string handler); 

Sets the processing instruction (PI) handler function for the XML parser parser, handler is a string 
containing the name of a function that must exist when xml_parse() is called for parser. 

A processing instruction has the following format: 

<? 

target 
datal> 

You can put PHP code into such a tag, but be aware of one limitation: in an XML PI, the PI end tag 
(? >) can not be quoted, so this character sequence should not appear in the PHP code you embed with 
Pis in XML documents. If it does, the rest of the PHP code, as well as the "real" PI end tag, will be 
treated as character data. 

The function named hy handler must accept three parameters: 
handler(\n\. parser, string target, string data); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

target 

The second parameter, target, contains the PI target. 

data 

The third parameter, data, contains the PI data. 
If a handler function is set to an empty string, or false, the handler in question is disabled. 
True is returned if the handler is set up, false if parser is not a parser. 
There is currently no support for object/method handlers. 



Prev Home Next 

xml_set_character_data_handler Ug xml_set_default_handler 



PHP Manual 

Prev Next 



xml_set_default_handler 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_set_default_handler ~ set up default handler 

Description 

int xml_set_def ault_handler (int parser, string handler); 

Sets the default handler function for the XML parser parser, handler is a string containing the 
name of a function that must exist when xml_parse() is called for parser. 

The function named by handler must accept two parameters: 
handler(mt parser, string data); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

data 

The second parameter, data, contains the character data. This may be the XML declaration, 
document type declaration, entities or other data for which no other handler exists. 

If a handler function is set to an empty string, or false, the handler in question is disabled. 

True is returned if the handler is set up, false if parser is not a parser. 

There is currently no support for object/method handlers. 

Prev Home Next 

xml_set_processing_instruction_handler Up xml_set_unparsed_entity_decl_handler 



PHP Manual 

Prev Next 



xml_set_unparsed_entity_decl_handler 



■This function is not supported in the^^B 
IpHP Lite edition. ^ 

IPossible workaround not yet publisli^^B 



xml_set_unparsed_entity_decl_handler — Set up unparsed entity declaration handler 

Description 

int xml_set_unparsed_entity_decl_handler (int parser, string handler); 

Sets the unparsed entity declaration handler function for the XML parser parser, handler is a 
string containing the name of a function that must exist when xml_parse() is called for parser. 

This handler will be called if the XML parser encounters an external entity declaration with an 
NDATA declaration, like the following: 

<! ENTITY name {publicid | systemid] NDATA notationName> 

See section 4.2.2 of the XML 1.0 spec for the definition of notation declared external entities. 

The function named by handler must accept six parameters: 

handler(mt parser, string entityName, string base, string systemid, string publicid, string 
notationName); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

entityName 

The name of the entity that is about to be defined. 

base 

This is the base for resolving the system identifier (systemid) of the external entity. 
Currently this parameter will always be set to an empty string. 

systemid 

System identifier for the external entity. 

publicid 

Public identifier for the external entity. 



not at! onName 

Name of the notation of this entity (see xml_set_notation_decl_handler() ). 
If a handler function is set to an empty string, or false, the handler in question is disabled. 
True is returned if the handler is set up, false if parser is not a parser. 
There is currently no support for object/method handlers. 

Prev Home Next 

xml_set_default_handler Ug xml_set_notation_decl_handler 



PHP Manual 

Prev Next 



xml set notation decl handler 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_set_notation_decl_handler ~ set up notation declaration handler 

Description 

int xml_set_notation_decl_handler (int parser, string handler); 

Sets the notation declaration handler function for the XML parser parser, handler is a string 
containing the name of a function that must exist when xml_parse() is called for parser. 

A notation declaration is part of the document's DTD and has the following format: 

<! NOTATION 

name { systemid \ 
puhlicld) > 

See section 4.7 of the XML 1.0 spec for the definition of notation declarations. 

The function named by handler must accept five parameters: 

handler(int parser, string notationName, string base, string systemid, string publicid); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

not at! onName 

This is the notation's name, as per the notation format described above. 

base 

This is the base for resolving the system identifier (systemid) of the notation declaration. 
Currently this parameter will always be set to an empty string. 

systemid 

System identifier of the external notation declaration. 

publicid 

Public identifier of the external notation declaration. 



If a handler function is set to an empty string, or false, ttie liandler in question is disabled. 
True is returned if the handler is set up, false if parser is not a parser. 
There is currently no support for object/method handlers. 

Prev Home Next 

xml_set_unparsed_entity_decl_handler Up xml_set_external_entity_ref_handler 



PHP Manual 

Prev Next 



xml_set_external_entity_ref_handler 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_set_external_entity_ref_handler ~ set up external entity reference handler 

Description 

int xml_set_external_entity_ref_handler (int parser, string handler); 

Sets the notation declaration handler function for the XML parser parser, handler is a string 
containing the name of a function that must exist when xml_parse() is called for parser. 

The function named by handler must accept five parameters, and should return an integer value. 
If the value returned from the handler is false (which it will be if no value is returned), the XML 
parser will stop parsing and xml_get_error_code() will return 
XML_ERROR_EXTERNAL_ENTITY_HANDLING. 

int handler(int parser, string openEntityNames , string base, string systemid, string publicid); 

parser 

The first parameter, parser, is a reference to the XML parser calling the handler. 

openEntityNames 

The second parameter, openEntityNames, is a space-separated list of the names of the 
entities that are open for the parse of this entity (including the name of the referenced entity). 

base 

This is the base for resolving the system identifier (systemid) of the external entity. 
Currently this parameter will always be set to an empty string. 

systemid 

The fourth parameter, systemid, is the system identifier as specified in the entity 
declaration. 

publicid 

The fifth parameter, publicid, is the public identifier as specified in the entity declaration, 
or an empty string if none was specified; the whitespace in the public identifier will have 
been normalized as required by the XML spec. 



If a handler function is set to an empty string, or false, the handler in question is disabled. 
True is returned if the handler is set up, false if parser is not a parser. 
There is currently no support for object/method handlers. 

Prev Home Next 

xml_set_notation_decl_handler Up xml_parse 



PHP Manual 

Prev Next 



xml_parser_get_option 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_parser_get_option ~ get options from an XML parser 

Description 

mixed xml_parser_get_option (int parser, int option); 

parser 

A reference to the XML parser to get an option from. 

option 

Which option to fetch. See xml_parser_set_option() for a Hst of options. 

This function returns false if parser does not refer to a vahd parser, or if the option could not be 
set. Else the option's value is returned. 

See xml_parser_set_option() for the list of options. 

Prev Home Next 

xml_parser_set_option U^ utf8_decode 



PHP Manual 

Prev Next 



xml_parse 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_parse ~ start parsing an XML document 

Description 

int xml_par se(int parser, string data, int [isFinal] ); 

parser 

A reference to the XML parser to use. 



data 

Chunk of data to parse. A document may be parsed piece-wise by calhng xml_parse() 
several times with new data, as long as the IsFinal parameter is set and true when the last 
data is parsed. 

IsFinal (optional) 

If set and true, da t a is the last piece of data sent in this parse. 

When the XML document is parsed, the handlers for the configured events are called as many times 
as necessary, after which this function returns true or false. 

True is returned if the parse was successful, false if it was not successful, or if parser does not 
refer to a valid parser. For unsuccessful parses, error information can be retrieved with 
xml_get_error_code() , xml_error_string() , xml_get_current_line_number() , 
xml_get_current_column_number() and xml_get_current_by te_index() . 

Prev Home Next 

xml_set_external_entity_ref_handler Up xml_get_error_code 



PHP Manual 

Prev Next 



xml_set_obiect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_set_object ~ Use XML Parser withing an object 

Description 

void xml_set_object(int parser, object &object); 

This function makes parser useable from within object. All callback functions settet via 
xml_set_element_handler() etc are assumed to be methods of object. 

<?php 

class xml { 

var $parser; 

function xml ( ) { 

$this->parser = xml_parser_create ( ) ; 

xml_set_ob ject ($this->parser, &$this) ; 

xml_set_element_handler ( $this->parser , "tag_open" , "tag_close" ) ; 

xml_set_character_data_handler ($this->parser, "cdata") ; 
} 

function parse ($data) { 

xml_parse ($this->parser, $data) ; 
} 

function tag_open ($parser, $tag, $attributes) { 

var_dump ($parser, $tag, $attributes) ; 
} 

function cdata ($parser, $cdata) { 

var_dump ($parser, $cdata) ; 
} 

function tag_close ($parser, $tag) { 
var_dump ($parser, $tag) ; 



} // end of class xml 

$xml_parser = new xml ( ) ; 

$xml_parser->parse ( "<A ID=\ "hallo\">PHP</A>" ) ; 

?> 



Note: xml_set_object() handling was added in PHP 4.0. 

Prev Home Next 

xml_parser_create U^ xml_set_element_handler 



PHP Manual 

Prev Next 



xml_get_error_code 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_get_error_code ~ get XML parser error code 

Description 

int xml_get_error_code(int parser); 
parser 

A reference to the XML parser to get error code from. 

This function returns false if parser does not refer to a vahd parser, or else it returns one of the 
error codes listed in the error codes section . 

Prev Home Next 

xml_parse U^ xml_error_string 



PHP Manual 

Prev Next 



xml_error_string 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_error_string ~ get XML parser error string 

Description 

string xml_error_string(int code); 
code 

An error code from xml_get_error_code() . 

Returns a string with a textual description of the error code code, or false if no description was 
found. 

Prev Home Next 

xml_get_error_code U^ xml_get_current_line_number 



PHP Manual 

Prev Next 



xml_get_current_line_n umber 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_get_current_Hne_number ~ get current Hne number for an XML parser 

Description 

int xml_get_current_line_number (int parser); 

parser 

A reference to the XML parser to get Hne number from. 

This function returns false if parser does not refer to a vahd parser, or else it returns which line 
the parser is currently at in its data buffer. 

Prev Home Next 

xml_error_string Up xml_get_current_column_number 



PHP Manual 

Prev Next 



xml_get_current_column_number 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_get_current_column_number ~ Get current column number for an XML parser 

Description 

int xml_get_current_column_number (int parser); 

parser 

A reference to the XML parser to get column number from. 

This function returns false if parser does not refer to a valid parser, or else it returns which 
column on the current line (as given by xml_get_current_line_number() ) the parser is currently 

at. 

Prev Home Next 

xml_get_current_line_number Ug xml_get_current_byte_index 



PHP Manual 

Prev Next 



xm l_get_cu r rent_by te_i ndex 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



xml_get_current_byte_index ~ get current byte index for an XML parser 

Description 

int xml_get_current_byte_index (int parser); 

parser 

A reference to the XML parser to get byte index from. 

This function returns false if parser does not refer to a vahd parser, or else it returns which byte 
index the parser is currently at in its data buffer (starting at 0). 

Prev Home Next 

xml_get_current_column_number Up xml_parser_free 



PHP Manual 

Prev Next 



xml_parser_free 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

xml_parser_free ~ Free an XML parser 

Description 

string xml_parser_f ree(int parser); 
parser 

A reference to the XML parser to free. 

This function returns false if parser does not refer to a vahd parser, or else it frees the parser and 
returns true. 

Prev Home Next 

xml_get_current_byte_index Ug xml_parser_set_option 



PHP Manual 

Prev Next 



utf8 decode 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



utf8_decode ~ Converts a UTF-8 encoded string to ISO-8859-1 

Description 

string utf 8_decode(string data); 

This function decodes data, assumed to be UTF-8 encoded, to ISO-8859-1. 

See utf8_encode() for an explaination of UTF-8 encoding. 

Prev Home Next 

xml_parser_get_option U^ utf8_encode 



PHP Manual 



Prev 



Next 



utf8 encode 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



edJ 



utf8_encode ~ encodes an ISO-8859-1 string to UTF-8 



Description 



string utf 8_encode(string data); 

This function encodes the string data to UTF-8, and returns the encoded version. UTF-8 is a 
standard mechanism used by Unicodefor encoding wide character values into a byte stream. 
UTF-8 is transparent to plain ASCII characters, is self-synchronized (meaning it is possible for a 
program to figure out where in the bytestream characters start) and can be used with normal string 
comparison functions for sorting and such. PHP encodes UTF-8 characters in up to four bytes, like 
this: 

Table 1. UTF-8 encoding 



bytes 


bits 


representation 


1 


7 


Obbbbbbb 


2 


11 


llObbbbb lObbbbbb 


3 


16 


lllObbbb lObbbbbb lObbbbbb 


4 


21 


llllObbb lObbbbbb lObbbbbb lObbbbbb 



Each h represents a bit that can be used to store character data. 



Prev 

utf8 decode 



Home 
UE 



Next 
Appendixes 



PHP Manual 

Prev Next 



set_magic_quotes_runtime 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



set_magic_quotes_runtime ~ Set the current active configuration setting of magic_quotes_runtime. 

Description 

long set_magic_quotes_runtime(int new_setting); 

Set the current active configuration setting of magic_quotes_runtime . (0 for off, 1 for on) 

See also get_magic_quotes_gpc() , get_magic_quotes_runtime() . 

Prev Home Next 

putenv Up set_time_Hmit 



PHP Manual 

Prev Next 



XLIII. POSIX functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



This module contains an interface to those functions defined in the IEEE 1003.1 (POSIX. 1) 
standards document which are not accessible through other means. POSIX. 1 for example defined 
the open(), read(), write() and close() functions, too, which traditionally have been part of PHP3 for 
a long time. Some more system specific functions have not been available before, though, and this 
module tries to remedy this by providing easy access to these functions. 

Table of Contents 

// posix_kill Send a signal to a process 

// posix_getpid Return the current process identifier 

// posix_getppid Return the parent process identifier 

// posix_getuid Return the real user ID of the current process 

// posix_geteuid Return the effective user ID of the current process 

// posix_getgid Return the real group ID of the current process 

// posix_getegid Return the effective group ID of the current process 

// posix_setuid Set the effective UID of the current process 

// posix_setgid Set the effective GID of the current process 

// posix_getgroups Return the group set of the current process 

// posix_getlogin Return login name 

// posix_getpgrp Return the current process group identifier 

// posix_setsid Make the current process a session leader 

// posix_setpgid set process group id for job control 

// posix_getpgid Get process group id for job control 

// posix_setsid Get the current sid of the process 

// posix_uname Get system name 

// posix_times Get process times 

// posix_ctermid Get path name of controlling terminal 



// posix_ttyname Determine terminal device name 

// posix_isatty Determine if a file descriptor is an interactive terminal 

// posix_getcwd Pathname of current directory 

// posix_mkfifo Create a fifo special file (a named pipe) 

// posix_getgrnam Return info about a group by name 

// posix_getgrgid Return info about a group by group id 

// posix_getpwnam Return info about a user by name 

// posix_getpwuid Return info about a user by user id 

// posix_getrlimit Return info about system ressource limits 

Prev Home Next 

set_time_limit Up posix_kill 



PHP Manual 

Prev Next 



getmyuid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getmyuid ~ Get PHP script owner's UID. 

Description 

int getmyuid(void); 

Returns the user ID of the current script, or false on error. 

See also getmypidQ , get_current_user () , getmyinodeQ , and getlastmodQ . 

Prev Home Next 

getmypid U^ getrusage 



PHP Manual 

Prev Next 



putenv 

putenv ~ Set the value of an environment variable. 

Description 

void putenv(string setting); 

Adds settingto the environment. 
Example 1. Setting an Environment Variable 

putenv ( "UNIQID=$uniqid" ) ; 

Prev Home Next 

phpversion Ug set_magic_quotes_runtime 



PHP Manual 

Prev Next 



Pattern Syntax 

Pattern Syntax ~ describes PCRE regex syntax 

Description 



The PCRE library is a set of functions that implement regular 
expression pattern matching using the same syntax and semantics 
as Perl 5, with just a few differences (see below). The current 
implementation corresponds to Perl 5.005. 



Differences From Perl 

The differences described here are with respect to Perl 
5.005. 

1 . By default, a whitespace character is any character that 
the C library function isspace() recognizes, though it is 
possible to compile PCRE with alternative character type 
tables. Normally isspace() matches space, formfeed, newline, 
carriage return, horizontal tab, and vertical tab. Perl 5 no 
longer includes vertical tab in its set of whitespace char- 
acters. The \v escape that was in the Perl documentation for 

a long time was never in fact recognized. However, the char- 
acter itself was treated as whitespace at least up to 5.002. 
In 5.004 and 5.005 it does not match \s. 

2. PCRE does not allow repeat quantifiers on lookahead 
assertions. Perl permits them, but they do not mean what you 
might think. For example, (?!a){3} does not assert that the 
next three characters are not "a". It just asserts that the 
next character is not "a" three times. 

3. Capturing subpattems that occur inside negative looka- 
head assertions are counted, but their entries in the 
offsets vector are never set. Perl sets its numerical vari- 
ables from any such patterns that are matched before the 
assertion fails to match something (thereby succeeding), but 
only if the negative lookahead assertion contains just one 
branch. 



4. Though binary zero characters are supported in the sub- 
ject string, they are not allowed in a pattern string 
because it is passed as a normal C string, terminated by 
zero. The escape sequence "\0" can be used in the pattern to 
represent a binary zero. 

5. The following Perl escape sequences are not supported: 
\1, \u, \L, \U, \E, \Q. In fact these are implemented by 
Perl's general string-handling and are not part of its pat- 
tern matching engine. 

6. The Perl \G assertion is not supported as it is not 
relevant to single pattern matches. 

7. Fairly obviously, PCRE does not support the (?{code}) 
construction. 

8. There are at the time of writing some oddities in Perl 
5.005_02 concerned with the settings of captured strings 
when part of a pattern is repeated. For example, matching 
"aba" against the pattern /^(a(b)?)+$/ sets $2 to the value 
"b", but matching "aabbaa" against /^(aa(bb)?)+$/ leaves $2 
unset. However, if the pattern is changed to 
/^(aa(b(b))?)+$/ then $2 (and $3) get set. 

In Perl 5.004 $2 is set in both cases, and that is also true 
of PCRE. If in the future Perl changes to a consistent state 
that is different, PCRE may change to follow. 

9. Another as yet unresolved discrepancy is that in Perl 
5.005_02 the pattern /^(a)?(?(l)alb)+$/ matches the string 
"a", whereas in PCRE it does not. However, in both Perl and 
PCRE /^(a)?a/ matched against "a" leaves $1 unset. 

10. PCRE provides some extensions to the Perl regular 
expression facilities: 

(a) Although lookbehind assertions must match fixed length 
strings, each alternative branch of a lookbehind assertion 
can match a different length of string. Perl 5.005 requires 
them all to have the same length. 

(b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not 
set, the $ meta- character matches only at the very end of 

the string. 



(c) If PCRE_EXTRA is set, a backslash followed by a letter 
with no special meaning is faulted. 

(d) If PCRE_UNGREEDY is set, the greediness of the repeti- 
tion quantifiers is inverted, that is, by default they are 

not greedy, but if followed by a question mark they are. 



Regular Expression Details 

The syntax and semantics of the regular expressions sup- 
ported by PCRE are described below. Regular expressions are 
also described in the Perl documentation and in a number of 
other books, some of which have copious examples. Jeffrey 
Friedl's "Mastering Regular Expressions", published by 
O'Reilly (ISBN 1-56592-257-3), covers them in great detail. 
The description here is intended as reference documentation. 

A regular expression is a pattern that is matched against a 
subject string from left to right. Most characters stand for 
themselves in a pattern, and match the corresponding charac- 
ters in the subject. As a trivial example, the pattern 

The quick brown fox 

matches a portion of a subject string that is identical to 
itself. The power of regular expressions comes from the 
ability to include alternatives and repetitions in the pat- 
tern. These are encoded in the pattern by the use of meta- 
characters, which do not stand for themselves but instead 
are interpreted in some special way. 

There are two different sets of meta-characters: those that 
are recognized anywhere in the pattern except within square 
brackets, and those that are recognized in square brackets. 
Outside square brackets, the meta-characters are as follows: 

\ general escape character with several uses 
^ assert start of subject (or line, in multiline 
mode) 
$ assert end of subject (or line, in multiline mode) 
match any character except newline (by default) 
[ start character class definition 
I start of alternative branch 
( start subpattern 
) end subpattern 
? extends the meaning of ( 



also or 1 quantifier 

also quantifier minimizer 
* or more quantifier 
+ 1 or more quantifier 
{ start min/max quantifier 

Part of a pattern that is in square brackets is called a 
"character class". In a character class the only meta- 
characters are: 

\ general escape character 

^ negate the class, but only if the first character 

indicates character range 
] terminates the character class 

The following sections describe the use of each of the 
meta-characters. 

BACKSLASH 

The backslash character has several uses. Firstly, if it is 
followed by a non-alphameric character, it takes away any 
special meaning that character may have. This use of 
backslash as an escape character applies both inside and 
outside character classes. 

For example, if you want to match a "*" character, you write 
"\*" in the pattern. This applies whether or not the follow- 
ing character would otherwise be interpreted as a meta- 
character, so it is always safe to precede a non-alphameric 
with "\" to specify that it stands for itself. In particu- 
lar, if you want to match a backslash, you write "W". 

If a pattern is compiled with the PCRE_EXTENDED option, whi- 
tespace in the pattern (other than in a character class) and 
characters between a "#" outside a character class and the 
next newline character are ignored. An escaping backslash 
can be used to include a whitespace or "#" character as part 
of the pattern. 

A second use of backslash provides a way of encoding non- 
printing characters in patterns in a visible manner. There 
is no restriction on the appearance of non-printing charac- 
ters, apart from the binary zero that terminates a pattern, 
but when a pattern is being prepared by text editing, it is 
usually easier to use one of the following escape sequences 
than the binary character it represents: 



\a alarm, that is, the BEL character (hex 07) 

\cx "control-x", where x is any character 

\e escape (hex IB) 

\f formfeed (hex OC) 

\n newHne (hex OA) 

\r carriage return (hex OD) 

\t tab (hex 09) 

\xhh character with hex code hh 

\ddd character with octal code ddd, or backreference 

The precise effect of "\cx" is as follows: if "x" is a lower 
case letter, it is converted to upper case. Then bit 6 of 
the character (hex 40) is inverted. Thus "\cz" becomes hex 
lA, but "\c{" becomes hex 3B, while "\c;" becomes hex 7B. 

After "\x", up to two hexadecimal digits are read (letters 
can be in upper or lower case). 

After "\0" up to two further octal digits are read. In both 
cases, if there are fewer than two digits, just those that 
are present are used. Thus the sequence "\0\x\07" specifies 
two binary zeros followed by a BEL character. Make sure you 
supply two digits after the initial zero if the character 
that follows is itself an octal digit. 

The handling of a backslash followed by a digit other than 
is complicated. Outside a character class, PCRE reads it 
and any following digits as a decimal number. If the number 
is less than 10, or if there have been at least that many 
previous capturing left parentheses in the expression, the 
entire sequence is taken as a back reference. A description 
of how this works is given later, following the discussion 
of parenthesized subpatterns. 

Inside a character class, or if the decimal number is 
greater than 9 and there have not been that many capturing 
subpatterns, PCRE re-reads up to three octal digits follow- 
ing the backslash, and generates a single byte from the 
least significant 8 bits of the value. Any subsequent digits 
stand for themselves. For example: 

\040 is another way of writing a space 

\40 is the same, provided there are fewer than 40 

previous capturing subpatterns 
\7 is always a back reference 
\1 1 might be a back reference, or another way of 

writing a tab 



\011 is always a tab 

\01 13 is a tab followed by the character "3" 

\1 13 is the character with octal code 113 (since there 

can be no more than 99 back references) 
\377 is a byte consisting entirely of 1 bits 
\8 1 is either a back reference, or a binary zero 

followed by the two characters "8" and "1" 

Note that octal values of 100 or greater must not be intro- 
duced by a leading zero, because no more than three octal 
digits are ever read. 

All the sequences that define a single byte value can be 
used both inside and outside character classes. In addition, 
inside a character class, the sequence "\b" is interpreted 
as the backspace character (hex 08). Outside a character 
class it has a different meaning (see below). 

The third use of backslash is for specifying generic charac- 
ter types: 

\d any decimal digit 

\D any character that is not a decimal digit 

\s any whitespace character 

\S any character that is not a whitespace character 

\w any "word" character 

\W any "non-word" character 

Each pair of escape sequences partitions the complete set of 
characters into two disjoint sets. Any given character 
matches one, and only one, of each pair. 

A "word" character is any letter or digit or the underscore 
character, that is, any character which can be part of a 
Perl "word". The definition of letters and digits is con- 
trolled by PCRE's character tables, and may vary if locale- 
specific matching is taking place (see "Locale support" 
above). For example, in the "fr" (French) locale, some char- 
acter codes greater than 128 are used for accented letters, 
and these are matched by \w. 

These character type sequences can appear both inside and 
outside character classes. They each match one character of 
the appropriate type. If the current matching point is at 
the end of the subject string, all of them fail, since there 
is no character to match. 



The fourth use of backslash is for certain simple asser- 
tions. An assertion specifies a condition that has to be met 
at a particular point in a match, without consuming any 
characters from the subject string. The use of subpatterns 
for more complicated assertions is described below. The 
backslashed assertions are 

\b word boundary 
\B not a word boundary 

\A start of subject (independent of multiline mode) 
\Z end of subject or newline at end (independent of 
multiline mode) 
\z end of subject (independent of multiline mode) 

These assertions may not appear in character classes (but 
note that "\b" has a different meaning, namely the backspace 
character, inside a character class). 

A word boundary is a position in the subject string where 
the current character and the previous character do not both 
match \w or \W (i.e. one matches \w and the other matches 
\W), or the start or end of the string if the first or last 
character matches \w, respectively. 

The VA, \Z, and \z assertions differ from the traditional 
circumflex and dollar (described below) in that they only 
ever match at the very start and end of the subject string, 
whatever options are set. They are not affected by the 
PCRE_NOTBOL or PCRE_NOTEOL options. The difference between 
XL and \z is that XL matches before a newline that is the 
last character of the string as well as at the end of the 
string, whereas \z matches only at the end. 

CIRCUMFLEX AND DOLLAR 

Outside a character class, in the default matching mode, the 
circumflex character is an assertion which is true only if 
the current matching point is at the start of the subject 
string. Inside a character class, circumflex has an entirely 
different meaning (see below). 

Circumflex need not be the first character of the pattern if 
a number of alternatives are involved, but it should be the 
first thing in each alternative in which it appears if the 
pattern is ever to match that branch. If all possible alter- 
natives start with a circumflex, that is, if the pattern is 
constrained to match only at the start of the subject, it is 
said to be an "anchored" pattern. (There are also other con- 



structs that can cause a pattern to be anchored.) 

A dollar character is an assertion which is true only if the 
current matching point is at the end of the subject string, 
or immediately before a newline character that is the last 
character in the string (by default). Dollar need not be the 
last character of the pattern if a number of alternatives 
are involved, but it should be the last item in any branch 
in which it appears. Dollar has no special meaning in a 
character class. 

The meaning of dollar can be changed so that it matches only 
at the very end of the string, by setting the 
PCRE_DOLLAR_ENDONLY option at compile or matching time. This 
does not affect the XL assertion. 

The meanings of the circumflex and dollar characters are 
changed if the PCRE_MULTILINE option is set. When this is 
the case, they match immediately after and immediately 
before an internal "\n" character, respectively, in addition 
to matching at the start and end of the subject string. For 
example, the pattern /^abc$/ matches the subject string 
"def\nabc" in multiline mode, but not otherwise. Conse- 
quently, patterns that are anchored in single line mode 
because all branches start with "^" are not anchored in mul- 
tiline mode. The PCRE_DOLLAR_ENDONLY option is ignored if 
PCRE_MULTILINE is set. 

Note that the sequences \A, \Z, and \z can be used to match 
the start and end of the subject in both modes, and if all 
branches of a pattern start with \A is it always anchored, 
whether PCRE MULTILINE is set or not. 



FULL STOP (PERIOD, DOT) 

Outside a character class, a dot in the pattern matches any 
one character in the subject, including a non-printing 
character, but not (by default) newline. If the PCRE_DOTALL 
option is set, then dots match newlines as well. The han- 
dling of dot is entirely independent of the handling of cir- 
cumflex and dollar, the only relationship being that they 
both involve newline characters. Dot has no special meaning 
in a character class. 



SQUARE BRACKETS 

An opening square bracket introduces a cliaracter class, ter- 
minated by a closing square bracket. A closing square 
bracket on its own is not special. If a closing square 
bracket is required as a member of the class, it should be 
the first data character in the class (after an initial cir- 
cumflex, if present) or escaped with a backslash. 

A character class matches a single character in the subject; 
the character must be in the set of characters defined by 
the class, unless the first character in the class is a cir- 
cumflex, in which case the subject character must not be in 
the set defined by the class. If a circumflex is actually 
required as a member of the class, ensure it is not the 
first character, or escape it with a backslash. 

For example, the character class [aeiou] matches any lower 
case vowel, while [^aeiou] matches any character that is not 
a lower case vowel. Note that a circumflex is just a con- 
venient notation for specifying the characters which are in 
the class by enumerating those that are not. It is not an 
assertion: it still consumes a character from the subject 
string, and fails if the current pointer is at the end of 
the string. 

When caseless matching is set, any letters in a class 
represent both their upper case and lower case versions, so 
for example, a caseless [aeiou] matches "A" as well as "a", 
and a caseless [^aeiou] does not match "A", whereas a ease- 
ful version would. 

The newline character is never treated in any special way in 
character classes, whatever the setting of the PCRE_DOTALL 
or PCRE_MULTILINE options is. A class such as [^a] will 
always match a newline. 

The minus (hyphen) character can be used to specify a range 
of characters in a character class. For example, [d-m] 
matches any letter between d and m, inclusive. If a minus 
character is required in a class, it must be escaped with a 
backslash or appear in a position where it cannot be inter- 
preted as indicating a range, typically as the first or last 
character in the class. 

It is not possible to have the literal character "]" as the 
end character of a range. A pattern such as [W-J46] is 
interpreted as a class of two characters ("W" and "-") fol- 
lowed by a literal string "46]", so it would match "W46]" or 



"-46]". However, if the "]" is escaped with a backslash it 
is interpreted as the end of range, so [W-\]46] is inter- 
preted as a single class containing a range followed by two 
separate characters. The octal or hexadecimal representation 
of "]" can also be used to end a range. 

Ranges operate in ASCII collating sequence. They can also be 
used for characters specified numerically, for example 
[\000-\037]. If a range that includes letters is used when 
caseless matching is set, it matches the letters in either 
case. For example, [W-c] is equivalent to [][\'^_^wxyzabc], 
matched caselessly, and if character tables for the "fr" 
locale are in use, [\xc8-\xcb] matches accented E characters 
in both cases. 

The character types \d, \D, \s, \S, \w, and \W may also 
appear in a character class, and add the characters that 
they match to the class. For example, [\dABCDEF] matches any 
hexadecimal digit. A circumflex can conveniently be used 
with the upper case character types to specify a more res- 
tricted set of characters than the matching lower case type. 
For example, the class [^\W_] matches any letter or digit, 
but not underscore. 

All non-alphameric characters other than \, -, ^ (at the 
start) and the terminating ] are non-special in character 
classes, but it does no harm if they are escaped. 



VERTICAL BAR 

Vertical bar characters are used to separate alternative 
patterns. For example, the pattern 

gilbertl Sullivan 

matches either "gilbert" or "sullivan". Any number of alter- 
natives may appear, and an empty alternative is permitted 
(matching the empty string). The matching process tries 
each alternative in turn, from left to right, and the first 
one that succeeds is used. If the alternatives are within a 
subpattern (defined below), "succeeds" means matching the 
rest of the main pattern as well as the alternative in the 
subpattern. 



INTERNAL OPTION SETTING 

The settings of PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, 
and PCRE_EXTENDED can be changed from within the pattern by 
a sequence of Perl option letters enclosed between "(?" and 
")". The option letters are 

i for PCRE_CASELESS 
m for PCRE_MULTILINE 
s for PCRE_DOTALL 
X for PCRE_EXTENDED 

For example, (?im) sets caseless, multiline matching. It is 

also possible to unset these options by preceding the letter 

with a hyphen, and a combined setting and unsetting such as 

(?im-sx), which sets PCRE_CASELESS and PCRE_MULTILINE while 

unsetting PCRE_DOTALL and PCRE_EXTENDED, is also permitted. 

If a letter appears both before and after the hyphen, the 

option is unset. 

The scope of these option changes depends on where in the 
pattern the setting occurs. For settings that are outside 
any subpattern (defined below), the effect is the same as if 
the options were set or unset at the start of matching. The 
following patterns all behave in exactly the same way: 

(?i)abc 
a(?i)bc 
ab(?i)c 
abc(?i) 

which in turn is the same as compiling the pattern abc with 
PCRE_CASELESS set. In other words, such "top level" set- 
tings apply to the whole pattern (unless there are other 
changes inside subpatterns). If there is more than one set- 
ting of the same option at top level, the rightmost setting 
is used. 

If an option change occurs inside a subpattern, the effect 
is different. This is a change of behaviour in Perl 5.005. 
An option change inside a subpattern affects only that part 
of the subpattern that follows it, so 

(a(?i)b)c 

matches abc and aBc and no other strings (assuming 
PCRE_CASELESS is not used). By this means, options can be 



made to have different settings in different parts of the 
pattern. Any changes made in one alternative do carry on 
into subsequent branches within the same subpattern. For 
example, 

(a(?i)blc) 

matches "ab", "aB", "c", and "C", even though when matching 
"C" the first branch is abandoned before the option setting. 
This is because the effects of option settings happen at 
compile time. There would be some very weird behaviour oth- 
erwise. 

The PCRE-specific options PCRE_UNGREEDY and PCRE_EXTRA can 

be changed in the same way as the Perl-compatible options by 

using the characters U and X respectively. The (?X) flag 

setting is special in that it must always occur earlier in 

the pattern than any of the additional features it turns on, 

even when it is at top level. It is best put at the start. 



SUBPATTERNS 

Subpatterns are delimited by parentheses (round brackets), 
which can be nested. Marking part of a pattern as a subpat- 
tern does two things: 

1. It localizes a set of alternatives. For example, the pat- 
tern 

cat(aractlerpillarl) 

matches one of the words "cat", "cataract", or "caterpil- 
lar". Without the parentheses, it would match "cataract", 
"erpillar" or the empty string. 

2. It sets up the subpattern as a capturing subpattern (as 
defined above). When the whole pattern matches, that por- 
tion of the subject string that matched the subpattern is 
passed back to the caller via the ovector argument of 
pcre_exec(). Opening parentheses are counted from left to 
right (starting from 1) to obtain the numbers of the captur- 
ing subpatterns. 

For example, if the string "the red king" is matched against 
the pattern 



the ((redlwhite) (kinglqueen)) 

the captured substrings are "red king", "red", and "king", 
and are numbered 1, 2, and 3. 

The fact that plain parentheses fulfil two functions is not 
always helpful. There are often times when a grouping sub- 
pattern is required without a capturing requirement. If an 
opening parenthesis is followed by "?:", the subpattern does 
not do any capturing, and is not counted when computing the 
number of any subsequent capturing subpatterns. For example, 
if the string "the white queen" is matched against the 
pattern 

the ((?:redlwhite) (kinglqueen)) 

the captured substrings are "white queen" and "queen", and 
are numbered 1 and 2. The maximum number of captured sub- 
strings is 99, and the maximum number of all subpatterns, 
both capturing and non-capturing, is 200. 

As a convenient shorthand, if any option settings are 
required at the start of a non-capturing subpattern, the 
option letters may appear between the "?" and the ":". Thus 
the two patterns 

(?i: Saturday Isunday) 
(?:(?i)saturdaylsunday) 

match exactly the same set of strings. Because alternative 
branches are tried from left to right, and options are not 
reset until the end of the subpattern is reached, an option 
setting in one branch does affect subsequent branches, so 
the above patterns match "SUNDAY" as well as "Saturday". 



REPETITION 

Repetition is specified by quantifiers, which can follow any 
of the following items: 

a single character, possibly escaped 
the . metacharacter 
a character class 

a back reference (see next section) 
a parenthesized subpattern (unless it is an assertion - 
see below) 



The general repetition quantifier specifies a minimum and 
maximum number of permitted matches, by giving the two 
numbers in curly brackets (braces), separated by a comma. 
The numbers must be less than 65536, and the first must be 
less than or equal to the second. For example: 

z{2,4} 

matches "zz", "zzz", or "zzzz". A closing brace on its own 
is not a special character. If the second number is omitted, 
but the comma is present, there is no upper limit; if the 
second number and the comma are both omitted, the quantifier 
specifies an exact number of required matches. Thus 

[aeiou]{3,} 

matches at least 3 successive vowels, but may match many 
more, while 

\d{8} 

matches exactly 8 digits. An opening curly bracket that 
appears in a position where a quantifier is not allowed, or 
one that does not match the syntax of a quantifier, is taken 
as a literal character. For example, {,6} is not a quantif- 
ier, but a literal string of four characters. 

The quantifier {0} is permitted, causing the expression to 
behave as if the previous item and the quantifier were not 
present. 

For convenience (and historical compatibility) the three 
most common quantifiers have single-character abbreviations: 

* is equivalent to {0,} 
+ is equivalent to { 1, } 
? is equivalent to { 0, 1 } 

It is possible to construct infinite loops by following a 
subpattern that can match no characters with a quantifier 
that has no upper limit, for example: 

(a?)* 

Earlier versions of Perl and PCRE used to give an error at 
compile time for such patterns. However, because there are 



cases where this can be useful, such patterns are now 
accepted, but if any repetition of the subpattern does in 
fact match no characters, the loop is forcibly broken. 

By default, the quantifiers are "greedy", that is, they 
match as much as possible (up to the maximum number of per- 
mitted times), without causing the rest of the pattern to 
fail. The classic example of where this gives problems is in 
trying to match comments in C programs. These appear between 
the sequences /* and */ and within the sequence, individual 
* and / characters may appear. An attempt to match C com- 
ments by applying the pattern 

to the string 

/* first command */ not comment /* second comment */ 

fails, because it matches the entire string due to the 
greediness of the .* item. 

However, if a quantifier is followed by a question mark, 
then it ceases to be greedy, and instead matches the minimum 
number of times possible, so the pattern 

does the right thing with the C comments. The meaning of the 
various quantifiers is not otherwise changed, just the pre- 
ferred number of matches. Do not confuse this use of ques- 
tion mark with its use as a quantifier in its own right. 
Because it has two uses, it can sometimes appear doubled, as 
in 

\d??\d 

which matches one digit by preference, but can match two if 
that is the only way the rest of the pattern matches. 

If the PCRE_UNGREEDY option is set (an option which is not 
available in Perl) then the quantifiers are not greedy by 
default, but individual ones can be made greedy by following 
them with a question mark. In other words, it inverts the 
default behaviour. 

When a parenthesized subpattern is quantified with a minimum 



repeat count that is greater than 1 or with a limited max- 
imum, more store is required for the compiled pattern, in 
proportion to the size of the minimum or maximum. 

If a pattern starts with .* or .{0,} and the PCRE_DOTALL 
option (equivalent to Perl's /s) is set, thus allowing the . 
to match newlines, then the pattern is implicitly anchored, 
because whatever follows will be tried against every charac- 
ter position in the subject string, so there is no point in 
retrying the overall match at any position after the first. 
PCRE treats such a pattern as though it were preceded by \A. 
In cases where it is known that the subject string contains 
no newlines, it is worth setting PCRE_DOTALL when the pat- 
tern begins with .* in order to obtain this optimization, or 
alternatively using ^ to indicate anchoring explicitly. 

When a capturing subpattern is repeated, the value captured 
is the substring that matched the final iteration. For exam- 
ple, after 

(tweedle[dume] { 3 }\s*)+ 

has matched "tweedledum tweedledee" the value of the cap- 
tured substring is "tweedledee". However, if there are 
nested capturing subpatterns, the corresponding captured 
values may have been set in previous iterations. For exam- 
ple, after 
/(al(b))+/ 

matches "aba" the value of the second captured substring is 
"b". 



BACK REFERENCES 

Outside a character class, a backslash followed by a digit 
greater than (and possibly further digits) is a back 
reference to a capturing subpattern earlier (i.e. to its 
left) in the pattern, provided there have been that many 
previous capturing left parentheses. 

However, if the decimal number following the backslash is 
less than 10, it is always taken as a back reference, and 
causes an error only if there are not that many capturing 
left parentheses in the entire pattern. In other words, the 
parentheses that are referenced need not be to the left of 
the reference for numbers less than 10. See the section 



entitled "Backslash" above for further details of the han- 
dling of digits following a backslash. 

A back reference matches whatever actually matched the cap- 
turing subpattern in the current subject string, rather than 
anything matching the subpattern itself. So the pattern 

(senslrespons)e and \libility 

matches "sense and sensibility" and "response and responsi- 
bility", but not "sense and responsibility". If easeful 
matching is in force at the time of the back reference, then 
the case of letters is relevant. For example, 

((?i)rah)\s+\l 

matches "rah rah" and "RAH RAH", but not "RAH rah", even 
though the original capturing subpattern is matched case- 
lessly. 

There may be more than one back reference to the same sub- 
pattern. If a subpattern has not actually been used in a 
particular match, then any back references to it always 
fail. For example, the pattern 

(al(bc))\2 

always fails if it starts to match "a" rather than "be". 
Because there may be up to 99 back references, all digits 
following the backslash are taken as part of a potential 
back reference number. If the pattern continues with a digit 
character, then some delimiter must be used to terminate the 
back reference. If the PCRE_EXTENDED option is set, this can 
be whitespace. Otherwise an empty comment can be used. 

A back reference that occurs inside the parentheses to which 
it refers fails when the subpattern is first used, so, for 
example, (a\l) never matches. However, such references can 
be useful inside repeated subpatterns. For example, the pat- 
tern 

(alb\l)+ 

matches any number of "a"s and also "aba", "ababaa" etc. At 
each iteration of the subpattern, the back reference matches 
the character string corresponding to the previous itera- 
tion. In order for this to work, the pattern must be such 



that the first iteration does not need to match the back 
reference. This can be done using alternation, as in the 
example above, or by a quantifier with a minimum of zero. 



ASSERTIONS 

An assertion is a test on the characters following or 
preceding the current matching point that does not actually 
consume any characters. The simple assertions coded as \b, 
\B, \A, \Z, \z, ^ and $ are described above. More compli- 
cated assertions are coded as subpatterns. There are two 
kinds: those that look ahead of the current position in the 
subject string, and those that look behind it. 

An assertion subpattern is matched in the normal way, except 
that it does not cause the current matching position to be 
changed. Lookahead assertions start with (?= for positive 
assertions and (?! for negative assertions. For example, 

\w+(?=;) 

matches a word followed by a semicolon, but does not include 
the semicolon in the match, and 

foo(?!bar) 

matches any occurrence of "foo" that is not followed by 
"bar". Note that the apparently similar pattern 

(?!foo)bar 

does not find an occurrence of "bar" that is preceded by 
something other than "foo"; it finds any occurrence of "bar" 
whatsoever, because the assertion (?!foo) is always true 
when the next three characters are "bar". A lookbehind 
assertion is needed to achieve this effect. 
Lookbehind assertions start with (?<= for positive asser- 
tions and (?<! for negative assertions. For example, 

(?<!foo)bar 

does find an occurrence of "bar" that is not preceded by 
"foo". The contents of a lookbehind assertion are restricted 
such that all the strings it matches must have a fixed 
length. However, if there are several alternatives, they do 
not all have to have the same fixed length. Thus 



(?<=bullockldonkey) 

is permitted, but 

(?<!dogs?lcats?) 

causes an error at compile time. Branches that match dif- 
ferent length strings are permitted only at the top level of 
a lookbehind assertion. This is an extension compared with 
Perl 5.005, which requires all branches to match the same 
length of string. An assertion such as 

(?<=ab(clde)) 

is not permitted, because its single top-level branch can 
match two different lengths, but it is acceptable if rewrit- 
ten to use two top-level branches: 

(?<=abclabde) 

The implementation of lookbehind assertions is, for each 
alternative, to temporarily move the current position back 
by the fixed width and then try to match. If there are 
insufficient characters before the current position, the 
match is deemed to fail. Lookbehinds in conjunction with 
once-only subpatterns can be particularly useful for match- 
ing at the ends of strings; an example is given at the end 
of the section on once-only subpatterns. 

Several assertions (of any sort) may occur in succession. 
For example, 

(?<=\d{3})(?<!999)foo 

matches "foo" preceded by three digits that are not "999". 
Furthermore, assertions can be nested in any combination. 
For example, 

(?<=(?< !foo)bar)baz 

matches an occurrence of "baz" that is preceded by "bar" 
which in turn is not preceded by "foo". 

Assertion subpatterns are not capturing subpatterns, and may 
not be repeated, because it makes no sense to assert the 
same thing several times. If an assertion contains capturing 



subpatterns within it, these are always counted for the pur- 
poses of numbering the capturing subpatterns in the whole 
pattern. Substring capturing is carried out for positive 
assertions, but it does not make sense for negative asser- 
tions. 

Assertions count towards the maximum of 200 parenthesized 
subpatterns. 



ONCE-ONLY SUBPATTERNS 

With both maximizing and minimizing repetition, failure of 
what follows normally causes the repeated item to be re- 
evaluated to see if a different number of repeats allows the 
rest of the pattern to match. Sometimes it is useful to 
prevent this, either to change the nature of the match, or 
to cause it fail earlier than it otherwise might, when the 
author of the pattern knows there is no point in carrying 
on. 

Consider, for example, the pattern \d+foo when applied to 
the subject line 

123456bar 

After matching all 6 digits and then failing to match "foo", 
the normal action of the matcher is to try again with only 5 
digits matching the \d+ item, and then with 4, and so on, 
before ultimately failing. Once-only subpatterns provide the 
means for specifying that once a portion of the pattern has 
matched, it is not to be re-evaluated in this way, so the 
matcher would give up immediately on failing to match "foo' 
the first time. The notation is another kind of special 
parenthesis, starting with (?> as in this example: 

(?>\d+)bar 

This kind of parenthesis "locks up" the part of the pattern 
it contains once it has matched, and a failure further into 
the pattern is prevented from backtracking into it. Back- 
tracking past it to previous items, however, works as nor- 
mal. 

An alternative description is that a subpattern of this type 
matches the string of characters that an identical stan- 
dalone pattern would match, if anchored at the current point 



in the subject string. 

Once-only subpatterns are not capturing subpatterns. Simple 
cases such as the above example can be thought of as a max- 
imizing repeat that must swallow everything it can. So, 
while both \d+ and \d+? are prepared to adjust the number of 
digits they match in order to make the rest of the pattern 
match, (?>\d+) can only match an entire sequence of digits. 

This construction can of course contain arbitrarily compli- 
cated subpatterns, and it can be nested. 

Once-only subpatterns can be used in conjunction with look- 
behind assertions to specify efficient matching at the end 
of the subject string. Consider a simple pattern such as 

abcd$ 

when applied to a long string which does not match it. 
Because matching proceeds from left to right, PCRE will look 
for each "a" in the subject and then see if what follows 
matches the rest of the pattern. If the pattern is specified 

as 

^.*abcd$ 

then the initial .* matches the entire string at first, but 
when this fails, it backtracks to match all but the last 
character, then all but the last two characters, and so on. 
Once again the search for "a" covers the entire string, from 
right to left, so we are no better off. However, if the pat- 
tern is written as 

^(?>.*)(?<=abcd) 

then there can be no backtracking for the .* item; it can 
match only the entire string. The subsequent lookbehind 
assertion does a single test on the last four characters. If 
it fails, the match fails immediately. For long strings, 
this approach makes a significant difference to the process- 
ing time. 



CONDITIONAL SUBPATTERNS 

It is possible to cause the matching process to obey a sub- 
pattern conditionally or to choose between two alternative 



subpatterns, depending on the result of an assertion, or 
whether a previous capturing subpattern matched or not. The 
two possible forms of conditional subpattern are 

(?(condition)yes-pattern) 
(?(condition)yes-patternlno-pattern) 

If the condition is satisfied, the yes-pattern is used; oth- 
erwise the no-pattern (if present) is used. If there are 
more than two alternatives in the subpattern, a compile-time 
error occurs. 

There are two kinds of condition. If the text between the 
parentheses consists of a sequence of digits, then the con- 
dition is satisfied if the capturing subpattern of that 
number has previously matched. Consider the following pat- 
tern, which contains non-significant white space to make it 
more readable (assume the PCRE_EXTENDED option) and to 
divide it into three parts for ease of discussion: 

(\()? [\)]+ (?(1)\)) 

The first part matches an optional opening parenthesis, and 
if that character is present, sets it as the first captured 
substring. The second part matches one or more characters 
that are not parentheses. The third part is a conditional 
subpattern that tests whether the first set of parentheses 
matched or not. If they did, that is, if subject started 
with an opening parenthesis, the condition is true, and so 
the yes-pattern is executed and a closing parenthesis is 
required. Otherwise, since no-pattern is not present, the 
subpattern matches nothing. In other words, this pattern 
matches a sequence of non-parentheses, optionally enclosed 
in parentheses. 

If the condition is not a sequence of digits, it must be an 
assertion. This may be a positive or negative lookahead or 
lookbehind assertion. Consider this pattern, again contain- 
ing non- significant white space, and with the two alterna- 
tives on the second line: 

(?(?=[^a-z]*[a-z]) 

\d{2}[a-z]{3}-\d{2} I \d{2}-\d{2}-\d{2} ) 

The condition is a positive lookahead assertion that matches 
an optional sequence of non-letters followed by a letter. In 
other words, it tests for the presence of at least one 



letter in the subject. If a letter is found, the subject is 
matched against the first alternative; otherwise it is 
matched against the second. This pattern matches strings in 
one of the two forms dd-aaa-dd or dd-dd-dd, where aaa are 
letters and dd are digits. 



COMMENTS 

The sequence (?# marks the start of a comment which 
continues up to the next closing parenthesis. Nested 
parentheses are not permitted. The characters that make up a 
comment play no part in the pattern matching at all. 

If the PCRE_EXTENDED option is set, an unescaped # character 
outside a character class introduces a comment that contin- 
ues up to the next newline character in the pattern. 



PERFORMANCE 

Certain items that may appear in patterns are more efficient 
than others. It is more efficient to use a character class 
like [aeiou] than a set of alternatives such as (alelilolu). 
In general, the simplest construction that provides the 
required behaviour is usually the most efficient. Jeffrey 
Friedl's book contains a lot of discussion about optimizing 
regular expressions for efficient performance. 

When a pattern begins with .* and the PCRE_DOTALL option is 
set, the pattern is implicitly anchored by PCRE, since it 
can match only at the start of a subject string. However, if 
PCRE_DOTALL is not set, PCRE cannot make this optimization, 
because the . metacharacter does not then match a newline, 
and if the subject string contains newlines, the pattern may 
match from the character immediately following one of them 
instead of from the very start. For example, the pattern 

(.*) second 

matches the subject "first\nand second" (where \n stands for 
a newline character) with the first captured substring being 
"and". In order to do this, PCRE has to retry the match 
starting after every newline in the subject. 

If you are using such a pattern with subject strings that do 
not contain newlines, the best performance is obtained by 



setting PCRE_DOTALL, or starting the pattern with ^.* to 
indicate expHcit anchoring. That saves PCRE from having to 
scan along the subject looking for a newline to restart at. 



Prev Home Next 

Pattern Modifiers Up PHP options & information 



PHP Manual 

Prev Next 



errorjog 

error_log ~ send an error message somewhere 

Description 



int error_log(string message, int message_type, string [destination], string [extra_headers]); 

Sends an error message to the web server's error log, a TCP port or to a file. The first parameter, 
message, is the error message that should be logged. The second parameter, message_type 
says where the message should go: 

Table 1. error_log() log types 







message is sent to PHP's system logger, using the Operating System's system logging 
mechanism or a file, depending on what the error_log configuration directive is set to. 



message is sent by email to the address in the destination parameter. This is the only 
message type where the fourth parameter, extra_headers is used. This message type uses 
the same internal function as MailQ does. 



/message is sent through the PHP debugging connection. This option is only available if 
remote debugging has been enabled . In this case, the destination parameter specifies the 



host name or IP address and optionally, port number, of the socket receiving the debug 
information. 



message is appended to the file destination. 



Example 1. error_log() examples 

// Send notification through the server log if we can not 

// connect to the database. 

if ( ! Ora_Logon ( $username, $password) ) { 

error_log ( "Oracle database not available!", 0); 
} 

// Notify administrator by email if we run out of FOO 
if (!($foo = allocate_new_f oo ( ) ) { 

error_log ( "Big trouble, we're all out of FOOs!", 1, 
"operator@mydomain.com") ; 
} 



// other ways of calling error_log() : 
error_log ( "You messed up 
error_log ( "You messed up 
error_log ( "You messed up 



", 2, "127.0.0.1:7000"); 

", 2, "loghost"); 

", 3, " /var/tmp/my-errors . log" ) ; 



Prev Home Next 

PHP options & information Up error_reporting 



PHP Manual 



Prev 



Next 



error_reporting 



error_reporting ~ set which PHP errors are reported 



Description 



int error_reporting(int [level]); 

Sets PHP's error reporting level and returns the old level. The error reporting level is a bitmask of 
the following values (follow the links for the internal values to get their meanings): 

Table 1. error_reporting() bit values 



value 


internal name 


1 


E ERROR 




2 


E WARNING 




4 


E PARSE 




8 


E NOTICE 




16 


E CORE ERROR 




32 


E CORE WARNING 





Prev 
error_log 



Home 
Up 



Next 
extension loaded 



PHP Manual 

Prev Next 



extension loaded 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

extension_loaded ~ find out whether an extension is loaded 

Description 

bool extension_loaded(string name); 

Returns true if the extension identified by name is loaded. You can see the names of various 
extensions by using phpinfoQ . 

See also phpinfoQ . 

Note: This function was added in 3.0.10. 

Prev Home Next 

error_reporting Up getenv 



PHP Manual 

Prev Next 



get_magic_quotes_gpc 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

get_magic_quotes_gpc ~ Get the current active configuration setting of magic quotes gpc. 

Description 

long get_magic_quotes_gpc(void); 

Returns the current active configuration setting of magic_quotes_gpc . (0 for off, 1 for on) 

See also get_magic_quotes_runtime() , set_magic_quotes_runtime() . 

Prev Home Next 

get_current_user Ug get_magic_quotes_runtime 



PHP Manual 

Prev Next 



get_magic_quotes_runtime 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



get_magic_quotes_runtime ~ Get the current active configuration setting of magic_quotes_runtime. 

Description 

long get_magic_quotes_runtime(void); 

Returns the current active configuration setting of magic_quotes_runtime . (0 for off, 1 for on) 

See also get_magic_quotes_gpc() , set_magic_quotes_runtime() . 

Prev Home Next 

get_magic_quotes_gpc Ug getlastmod 



PHP Manual 

Prev Next 



getlastmod 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getlastmod ~ Get time of last page modification. 

Description 



int getlastmod(void); 

Returns the time of the last modification of the current page. The value returned is a Unix 
timestamp, suitable for feeding to dateQ . Returns false on error. 

Example 1. getlastmodQ example 

// outputs e.g. 'Last modified: March 04 1998 20:43:59.' 
echo "Last modified: ".date( "F d Y H:i:s.", getlastmod() ); 

See alse dateQ , getmyuidQ , get_current_user() , getmyinodeQ , and getmypidQ . 

Prev Home Next 

get_magic_quotes_runtime U^ getmyinode 



PHP Manual 

Prev Next 



getmyinode 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getmyinode ~ Get the inode of the current script. 

Description 

int getmyinode(void); 

Returns the current script's inode, or false on error. 

See also getmyuidQ , get_current_user () , getmypidQ , and getlastmodQ . 

Prev Home Next 

getlastmod U^ getmypid 



PHP Manual 

Prev Next 



getmypid 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



getmypid ~ Get PHP's process ID. 

Description 

int getmypid(void); 

Returns the current PHP process ID, or false on error. 

Note that when running as a server module, separate invocations of the script are not guaranteed to 
have distinct pids. 

See also getmyuidQ , get_current_user () , getmyinodeQ , and getlastmodQ . 

Prev Home Next 

getmyinode Up getmyuid 



PHP Manual 

Prev Chapter 12. Functions Next 



Function arguments 



Information may be passed to functions via the argument list, which is a comma-delimited list of 
variables and/or constants. 

PHP supports passing arguments by value (the default), passing by reference , and default argument 
values . Variable-length argument lists are supported only in PHP4 and later; see Variable-length 
argument lists and the function references for func_num_args() , func_get_arg() , and 
func_get_args() for more information. A similar effect can be achieved in PHP3 by passing an 
array of arguments to a function: 

function takes_array ($input ) { 

echo "$input[0] + $input[l] = ", $input [ ] +$input [ 1 ] ; 
} 



Making arguments be passed by reference 

By default, function arguments are passed by value (so that if you change the value of the argument 
within the function, it does not get changed outside of the function). If you wish to allow a function 
to modify its arguments, you must pass them by reference. 

If you want an argument to a function to always be passed by reference, you can prepend an 
ampersand (&) to the argument name in the function definition: 

function add_some_extra (&$string) { 

$string .= 'and something extra.'; 

} 

$str = 'This is a string, '; 

add_some_extra ( $str ) ; 

echo $str; // outputs 'This is a string, and something extra.' 

If you wish to pass a variable by reference to a function which does not do this by default, you may 
prepend an ampersand to the argument name in the function call: 

function foo ($bar) { 

$bar .= ' and something extra.'; 

} 

$str = 'This is a string, '; 

foo ($str ) ; 

echo $str; // outputs 'This is a string, ' 

foo (&$str ) ; 

echo $str; // outputs 'This is a string, and something extra.' 



Default argument values 

A function may define C++-style default values for scalar arguments as follows: 

function makecoffee ($type = "cappucino") { 
return "Making a cup of $type.\n"; 

} 

echo makecoffee (); 

echo makecoffee ("espresso"); 

The output from the above snippet is: 

Making a cup of cappucino. 
Making a cup of espresso. 

The default value must be a constant expression, not (for example) a variable or class member. 

In PHP 4.0 it's also possible to specify unset for default argument. This means that the argument 
will not be set at all, if a value is not supplied. 

Note that when using default arguments, any defaults should be on the right side of any non-default 
arguments; otherwise, things will not work as expected. Consider the following code snippet: 

function makeyogurt ($type = "acidophilus", $flavour) { 

return "Making a bowl of $type $f favour . \n" ; 
} 

echo makeyogurt ("raspberry"); // won't work as expected 

The output of the above example is: 

Warning: Missing argument 2 in call to makeyogurt ( ) in 
/usr/local/etc/httpd/htdocs/php3test/f unctest . html on line 41 
Making a bowl of raspberry . 

Now, compare the above with this: 

function makeyogurt ($f favour, $type = "acidophilus") { 

return "Making a bowl of $type $f favour . \n" ; 
} 

echo makeyogurt ("raspberry"); // works as expected 

The output of this example is: 

Making a bowl of acidophilus raspberry. 



Variable-length argument lists 

PHP4 has support for variable-length argument lists in user-defined functions. This is really quite 
easy, using the func_num_args() , func_get_arg() , and func_get_args() functions. 

No special syntax is required, and argument lists may still be explicitly provided with function 
definitions and will behave as normal. 

Prev Home Next 

Functions Up Returning values 



PHP Manual 

Prev Chapter 12. Functions Next 



Returning values 



Values are returned by using the optional return statement. Any type may be returned, including 
lists and objects. 

function square ($num) { 
return $num * $num; 

} 

echo square (4); // outputs '16'. 

You can't return multiple values from a function, but similar results can be obtained by returning a 
list. 

function small_numbers ( ) { 
return array (0, 1, 2); 

} 

list ($zero, $one, $two) = small_numbers ( ) ; 



Prev Home Next 

Function arguments Up old_f unction 



PHP Manual 

Prev Chapter 12. Functions Next 



old_f unction 

The old_f unction statement allows you to declare a function using a syntax identical to 
PHP/FI2 (except you must replace 'function' with 'old_function'. 

This is a deprecated feature, and should only be used by the PHP/FI2->PHP3 convertor. 



Warning 



Functions declared as old_f unction cannot be called from PHP's internal code. Among other 
things, this means you can't use them in functions such as usortQ , array_walk() , and 
register_shutdo wn_function() . You can get around this limitation by writing a wrapper function 



(in normal PHP3 form) to call the old_f unction. 



Prev Home Next 

Returning values U£ Variable functions 



PHP Manual 

Prev Chapter 12. Functions Next 



Variable functions 



PHP supports the concept of variable functions. This means that if a variable name has parentheses 
appended to it, PHP will look for a function with the same name as whatever the variable evaluates 
to, and will attempt to execute it. Among other things, this can be used to implement callbacks, 
function tables, and so forth. 

Example 12-1. Variable function example 

<?php 

function f oo ( ) { 

echo "In f oo ( ) <br>\n" ; 
} 

function bar ( $arg = ' ' ) { 

echo "In bar ( ) ; argument was ' $arg ' . <br>\n" ; 
} 

$f unc = ' f oo ' ; 

$func ; 

$f unc = 'bar ' ; 

$f unc ( ' test ' ) ; 

?> 



Prev Home Next 

old_f unction Up Classes and Objects 



PHP Manual 

Prev Next 



func_num_args 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

func_num_args ~ Returns the number of arguments passed to the function. 

Description 

int f unc_num_args(void ); 

Returns the number of arguments passed into the current user-defined function. func_num_args() 
will generate a warning if called from outside of a function definition. 

<?php 

function f oo ( ) { 

$numargs = f unc_num_args () ; 

echo "Number of arguments: $numargs\n"; 
} 

f oo ( 1, 2, 3 ); // Prints 'Number of arguments: 3' 
?> 



func_num_args() may be used in conjunction with func_get_arg() and func_get_args() to allow 
user-defined functions to accept variable-length argument lists. 

Note: This function was added in PHP 4. 

Prev Home Next 

func_get_args Up function_exists 



PHP Manual 



Prev 



Next 



func_get_args 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



|dJ 



func_get_args ~ Returns an array comprising a function's argument Hst. 

Description 

int f unc_get_args(void ); 

Returns an array in which each element is the corresponding member of the current user-defined 
function's argument hst. func_get_args() will generate a warning if called from outside of a 
function definition. 

<?php 

function f oo ( ) { 

$numargs = f unc_num_args () ; 

echo "Number of arguments: $numargs<br>\n" ; 

if ( $numargs >= 2 ) { 

echo "Second argument is: " . f unc_get_arg ( 1 ) . "<br>\n"; 



$arg_list = f unc_get_args ( ) ; 
for ( $i = 0; $i < $numargs 
echo "Argument $i is: " 



$i++ ) { 

$arg_list [$i] . "<br>\n"; 



} 



f oo ( 1, 2 , 3 ) ; 
?> 



func_get_args() may be used in conjunction with func_num_args() and func_get_arg() to allow 
user-defined functions to accept variable-length argument lists. 

Note: This function was added in PHP 4. 



Prev 
func_get_arg 



Home 
Up 



Next 
func_num_args 



PHP Manual 

Prev Chapter 10. Operators Next 



String Operators 



There are two string operators. The first is the concatenation operator ('.'), which returns the 
concatenation of its right and left arguments. The second is the concatenating assignment operator 
('.='). Please read Assignment Operators for more information. 

$a = "Hello "; 

$b = $a . "World!"; // now $b contains "Hello World!" 

$a = "Hello "; 

$a .= "World!"; // now $a contains "Hello World!" 



Prev Home Next 

Operator Precedence Up Control Structures 



PHP Manual 

Prev Chapter 11. Control Structures Next 



else 



Often you'd want to execute a statement if a certain condition is met, and a different statement if the 
condition is not met. This is what e 1 s e is for. else extends an i f statement to execute a 
statement in case the expression in the if statement evaluates to FALSE. For example, the 
following code would display a is bigger than b if $a is bigger than $b, and a is NOT 
bigger than b otherwise: 

if ($a > $b) { 

print "a is bigger than b"; 
} else { 

print "a is NOT bigger than b"; 
} 

The else statement is only executed if the if expression evaluated to FALSE, and if there were 
any el self expressions - only if they evaluated to FALSE as well (see below). 

Prev Home Next 

Control Structures Up el self 



PHP Manual 

Prev Chapter 11. Control Structures Next 



elseif 



elseif , as its name suggests, is a combination of if and else. Like else, it extends an if 
statement to execute a different statement in case the original if expression evaluates to FALSE. 
However, unlike else, it will execute that alternative expression only if the elseif conditional 
expression evaluates to TRUE. For example, the following code would display a is bigger 
than b, a equal to bora is smaller than b: 

if ($a > $b) { 

print "a is bigger than b"; 
} elseif ($a == $b) { 

print "a is equal to b"; 
} else { 

print "a is smaller than b"; 
} 

There may be several elseif s within the same if statement. The first elseif expression (if 
any) that evaluates to true would be executed. In PHP, you can also write 'else if (in two words) 
and the behavior would be identical to the one of 'elseif (in a single word). The syntactic meaning 
is slightly different (if you're familiar with C, this is the same behavior) but the bottom line is that 
both would result in exactly the same behavior. 

The elseif statement is only executed if the preceding if expression and any preceding 
elseif expressions evaluated to FALSE, and the current elseif expression evaluated to TRUE. 

Prev Home Next 

else Up Alternative syntax for control 

structures 



PHP Manual 

Prev Chapter 11. Control Structures Next 



Alternative syntax for control 
structures 

PHP offers an alternative syntax for some of its control structures; namely, if, while, for, and 
switch. In each case, the basic form of the alternate syntax is to change the opening brace to a 
colon (:) and the closing brace to endif ; , endwhile; , endf or; , or endswitch; , 
respectively. 

<?php if ($a==5) : ?> 
A is equal to 5 
<?php endif; ?> 

In the above example, the HTML block "A = 5" is nested within an if statement written in the 
alternative syntax. The HTML block would be displayed only if $a is equal to 5. 

The alternative syntax applies to e 1 s e and e 1 s e i f as well. The following is an i f structure with 
e 1 s e i f and e 1 s e in the alternative format: 

if ($a == 5) : 

print "a equals 5"; 

print "..."; 
elseif ($a == 6) : 

print "a equals 5"; 

print "!!!"; 
else : 

print "a is neither 5 nor 6"; 
endif; 



See also while, for, and if for further examples. 

Prev Home Next 

elseif Ug while 



PHP Manual 

Prev Chapter 11. Control Structures Next 



while loops are the simplest type of loop in PHP. They behave just like their C counterparts. The 
basic form of a while statement is: 

while (expr) statement 

The meaning of a while statement is simple. It tells PHP to execute the nested statement(s) 
repeatedly, as long as the while expression evaluates to TRUE. The value of the expression is 
checked each time at the beginning of the loop, so even if this value changes during the execution 
of the nested statement(s), execution will not stop until the end of the iteration (each time PHP runs 
the statements in the loop is one iteration). Sometimes, if the while expression evaluates to 
FALSE from the very beginning, the nested statement(s) won't even be run once. 

Like with the if statement, you can group multiple statements within the same while loop by 
surrounding a group of statements with curly braces, or by using the alternate syntax: 

while (expr) : statement . . . endwhile; 

The following examples are identical, and both print numbers from 1 to 10: 

/* example 1 */ 

$i = 1; 

while ($i <= 10) { 

print $i++; /* the printed value would be 

$i before the increment 
(post-increment) */ 
} 

/* example 2 */ 

$i = 1; 

while ($i <= 10) : 

print $i; 

$i++; 
endwhile; 



Prev Home Next 

Alternative syntax for control Ug do . .while 

structures 



PHP Manual 

Prev Chapter 11. Control Structures Next 



do. . 



do . . while loops are very similar to while loops, except the truth expression is checked at the 
end of each iteration instead of in the beginning. The main difference from regular while loops is 
that the first iteration of a do . .while loop is guarenteed to run (the truth expression is only 
checked at the end of the iteration), whereas it's may not necessarily run with a regular while loop 
(the truth expression is checked at the beginning of each iteration, if it evaluates to FALSE right 
from the beginning, the loop execution would end immediately). 

There is just one syntax for do . .while loops: 

$i = 0; 
do { 

print $i; 
} while ($i>0) ; 

The above loop would run one time exactly, since after the first iteration, when truth expression is 
checked, it evaluates to FALSE ($i is not bigger than 0) and the loop execution ends. 

Advanced C users may be familiar with a different usage of the do . .while loop, to allow 
stopping execution in the middle of code blocks, by encapsulating them with do . . while(O), and 
using the break statement. The following code fragment demonstrates this: 

do { 

if ($i < 5) { 

print "i is not big enough"; 
break; 

} 

$i *= $factor; 
if ($i < $minimum_limit ) { 
break; 

} 

print "i is ok"; 
. . .process i . . . 
} while (0) ; 

Don't worry if you don't understand this right away or at all. You can code scripts and even 
powerful scripts without using this ^feature'. 

Prev Home Next 

while Up for 



PHP Manual 

Prev Chapter 11. Control Structures Next 



for loops are the most complex loops in PHP. They behave like their C counterparts. The syntax 
of a for loop is: 

for (exprl; expr2; exprS) statement 

The first expression (exprl) is evaluated (executed) once unconditionally at the beginning of the 
loop. 

In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues 
and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends. 

At the end of each iteration, exprS is evaluated (executed). 

Each of the expressions can be empty. expr2 being empty means the loop should be run 
indefinitely (PHP implicitly considers it as TRUE, like C). This may not be as useless as you might 
think, since often you'd want to end the loop using a conditional break statement instead of using 
the for truth expression. 

Consider the following examples. All of them display numbers from 1 to 10: 

/* example 1 */ 

for ($i = 1; $i <= 10; $i++) { 

print $1; 
} 

/* example 2 */ 

for ($i = 1; ;$!++) { 
if ($i > 10) { 
break; 

} 

print $1; 

} 

/* example 3 */ 

$i = 1; 
for (;;) { 

if ($i > 10) { 
break; 

} 



print $i; 
$i++; 
} 

/* example 4 */ 

for ($i = 1; $i <= 10; print $1, $i++) ; 

Of course, the first example appears to be the nicest one (or perhaps the fourth), but you may find 
that being able to use empty expressions in for loops comes in handy in many occasions. 

PHP also supports the alternate "colon syntax" for for loops. 

for (exprl; expr2; exprS) : statement; ...; endfor; 

Other languages have a foreach statement to traverse an array or hash. PHP uses the while 
statement and the listQ and eachQ functions for this. See the documentation for these functions for 
an example. 

Prev Home Next 

do.. while Up break 



PHP Manual 

Prev Chapter 11. Control Structures Next 



break breaks out of the current looping control-structures. 

$i = 0; 

while ($i < 10) { 

if ($arr[$i] == "stop") { 
break; 

} 

$i++; 
} 



Prev Home Next 

for Up continue 



PHP Manual 

Prev Chapter 11. Control Structures Next 



continue 



continue is used within looping structures to skip the rest of the current loop iteration and 
continue execution at the beginning of the next iteration. 

while (list ($key, $value) = each($arr)) { 
if ($key % 2) { // skip even members 
continue; 

} 

do_something_odd ($value); 

} 



Prev Home Next 

break Up switch 



PHP Manual 

Prev Chapter 18. Handling file uploads Next 



PUT method support 



PHP provides support for the HTTP PUT method used by clients such as Netscape Composer and 
W3C Amaya. PUT requests are much simpler than a file upload and they look something like this: 

PUT /path/filename. html HTTP/1.1 

This would normally mean that the remote client would like to save the content that follows as: 
/path/filename. html in your web tree. It is obviously not a good idea for Apache or PHP to 
automatically let everybody overwrite any files in your web tree. So, to handle such a request you 
have to first tell your web server that you want a certain PHP script to handle the request. In 
Apache you do this with the Script directive. It can be placed almost anywhere in your Apache 
configuration file. A common place is inside a <Directory> block or perhaps inside a <Virtualhost> 
block. A line like this would do the trick: 

Script PUT /put.phpS 

This tells Apache to send all PUT requests for URIs that match the context in which you put this 
line to the put.phpS script. This assumes, of course, that you have PHP enabled for the .php3 
extension and PHP is active. 

Inside your put.php3 file you would then do something like this: 

<? copy ($PHP_UPLOADED_FILE_NAME, $DOCUMENT_ROOT.$REQUEST_URI) ; ?> 

This would copy the file to the location requested by the remote client. You would probably want to 
perform some checks and/or authenticate the user before performing this file copy. The only trick 
here is that when PHP sees a PUT-method request it stores the uploaded file in a temporary file just 
like those handled bu the POST-method . When the request ends, this temporary file is deleted. So, 
your PUT handling PHP script has to copy that file somewhere. The filename of this temporary file 
is in the $PHP_PUT_FILENAME variable, and you can see the suggested destination filename in 
the $REQUEST_URI (may vary on non- Apache web servers). This destination filename is the one 
that the remote client specified. You do not have to listen to this client. You could, for example, 
copy all uploaded files to a special uploads directory. 

Prev Home Next 

Uploading multiple files Ug Using remote files 



PHP Manual 

Prev Next 



Chapter 20. Connection handling 

Note: The following applies to 3.0.7 and later. 

Internally in PHP a connection status is maintained. There are 3 possible states: 

q 0- NORMAL 

q 1 - ABORTED 

q 2 -TIMEOUT 

When a PHP script is running normally the NORMAL state, is active. If the remote client 
disconnects the ABORTED state flag is turned on. A remote client disconnect is usually caused by 
the user hitting his STOP button. If the PHP-imposed time limit (see set_time_limit() ) is hit, the 
TIMEOUT state flag is turned on. 

You can decide whether or not you want a client disconnect to cause your script to be aborted. 
Sometimes it is handy to always have your scripts run to completion even if there is no remote 
browser receiving the output. The default behaviour is however for your script to be aborted when 
the remote client disconnects. This behaviour can be set via the ignore_user_abort php3.ini 
directive as well as through the corresponding php3_ignore_user_abort Apache .conf directive or 
with the ignore_user_abort() function. If you do not tell PHP to ignore a user abort and the user 
aborts, your script will terminate. The one exception is if you have registered a shutdown function 
using register_shutdown_function() . With a shutdown function, when the remote user hits his 
STOP button, the next time your script tries to output something PHP will detect that the 
connection has been aborted and the shutdown function is called. This shutdown function will also 
get called at the end of your script terminating normally, so to do something different in case of a 
client diconnect you can use the connection_aborted() function. This function will return true if 
the connection was aborted. 

Your script can also be terminated by the built-in script timer. The default timeout is 30 seconds. It 
can be changed using the max_execution_time php3.ini directive or the corresponding 
php3_max_execution_time Apache .conf directive as well as with the set_time_limit() function. 
When the timer expires the script will be aborted and as with the above client disconnect case, if a 
shutdown function has been registered it will be called. Within this shutdown function you can 
check to see if a timeout caused the shutdown function to be called by calling the 
connection_timeout() function. This function will return true if a timeout caused the shutdown 
function to be called. 

One thing to note is that both the ABORTED and the TIMEOUT states can be active at the same 
time. This is possible if you tell PHP to ignore user aborts. PHP will still note the fact that a user 
may have broken the connection, but the script will keep running. If it then hits the time limit it will 
be aborted and your shutdown function, if any, will be called. At this point you will find that 



connection_timeout() and connection_aborted() return true. You can also check both states in a 
single call by using the connection_status() . This function returns a bitfield of the active states. So, 
if both states are active it would return 3, for example. 

Prev Home Next 

Using remote files Ug Persistent database connections 



PHP Manual 

Prev Next 



syslog 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

syslog ~ generate a system log message 

Description 

int syslog(int priority, string message); 

syslogO generates a log message that will be distributed by the system logger, priority is a 
combination of the facility and the level, values for which are given in the next section. The 
remaining argument is the message to send, except that the two characters %m will be replaced by 
the error message string (strerror) corresponding to the present value of errno. 

More information on the syslog facilities can be found in the man pages for syslog on Unix 
machines. 

On Windows NT, the syslog service is emulated using the Event Log. 

Prev Home Next 

set_socket_blocking Ug NIS functions 



PHP Manual 

Prev Next 



. Features 



Table of Contents 

14. Error handling 

15. Creating GIF images 

16. HTTP authentication with PHP 

17. Cookies 

18. Handling file uploads 

19. Using remote files 

20. Connection handling 

2 1 . Persistent database connections 



Prev Home Next 

Classes and Objects Error handling 



PHP Manual 

Prev Next 



readlink 



readlink ~ Return the target of a symbolic link 

Description 

string readlink(string path); 

ReadlinkQ does the same as the readlink C function and returns the contents of the symbolic link 
path or in case of error. 

See also symlinkQ , readlink() and linkinfoQ . 

Prev Home Next 

readfile IJ£ rename 



PHP Manual 

Prev Next 



fpassthru 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fpassthru ~ output all remaining data on a file pointer 

Description 

int fpassthru(int fp); 

Reads to EOF on the given file pointer and writes the results to standard output. 

If an error occurs, fpassthru() returns false. 

The file pointer must be valid, and must point to a file successfully opened by fopenQ , popenQ , or 
fsockopenQ . The file is closed when fpassthru() is done reading it (leaving fp useless). 

If you just want to dump the contents of a file to stdout you may want to use the readfileQ , which 
saves you the fopenQ call. 

See also readfileQ , fopenQ , popenQ , and fsockopenQ 

Prev Home Next 

fopen Up fputs 



PHP Manual 

Prev Next 



file 

file ~ read entire file into an array 

Description 

array f ile(string filename, int [use_include_path]); 

Identical to readfileQ , except that file() returns the file in an array. Each element of the array 
corresponds to a line in the file, with the newline still attached. 

You can use the optional second parameter and set it to "1", if you want to search for the file in the 
include_path , too. 

See also readfileQ , fopenQ , and popenQ . 

Prev Home Next 

fgetss Up file_exists 



PHP Manual 

Prev Next 



fopen 

fopen ~ open file or URL 

Description 



int f open(string filename, string mode, int [use_include_path]); 

If filename begins with "http://" (not case sensitive), an HTTP 1.0 connection is opened to the 
specified server and a file pointer is returned to the beginning of the text of the response. 

Does not handle HTTP redirects, so you must include trailing slashes on directories. 

If filename begins with "ftp://" (not case sensitive), an ftp connection to the specified server is 
opened and a pointer to the requested file is returned. If the server does not support passive mode 
ftp, this will fail. You can open files for either reading and writing via ftp (but not both 
simultaneously). 

If filename begins with anything else, the file will be opened from the filesystem, and a file 
pointer to the file opened is returned. 

If the open fails, the function returns false. 

mode may be any of the following: 

q 'r' - open for reading only; place the file pointer at the beginning of the file. 

q 'r+' - Open for reading and writing; place the file pointer at the beginning of the file. 

q 'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the 
file to zero length. If the file does not exist, attempt to create it. 

q 'w+' - Open for reading and writing; place the file pointer at the beginning of the file and 
truncate the file to zero length. If the file does not exist, attempt to create it. 

q 'a' - Open for writing only; place the file pointer at the end of the file. If the file does not 
exist, attempt to create it. 

q 'a+' - Open for reading and writing; place the file pointer at the end of the file. If the file does 
not exist, attempt to create it. 

As well, mode may contain the letter 'b'. This is useful only on systems which differentiate between 
binary and text files (i.e., it's useless on Unix). If not needed, this will be ignored. 

You can use the optional third parameter and set it to "1", if you want to search for the file in the 
include_path , too. 



Example 1. fopenQ example 

$fp = f open ( " /home/rasmus/f ile . txt " , "r"); 

$fp = f open ( "http : //www. php . net/" , "r"); 

$fp = f open ( "ftp : //user :password@example . com/" , "w"); 

If you are experiencing problems with reading and writing to files and you're using the server 
module version of PHP, remember to make sure that the files and directories you're using are 
accessible to the server process. 

On the Windows platform, be careful to escape any backslashes used in the path to the file, or use 
forward slashes. 

$fp = f open ( "c : WdataWinf o . txt " , "r"); 
See also fcloseQ , fsockopenQ , and popenQ . 

Prev Home Next 

flock Ug fpassthru 



PHP Manual 

Prev Next 



XVII. Filesystem functions 

Table of Contents 

basename return filename component of path 

// chgrp change file group 

// chmod change file mode 

// chown change file owner 

// clearstatcache clear file stat cache 

copy copy file 

// delete a dummy manual entry 

dimame return directory name component of path 

// diskfreespace return available space in directory 

fclose close an open file pointer 

feof test for end-of-file on a file pointer 

// fgetc get character from file pointer 

// fgetcsv get line from file pointer and parse for CSV fields 

fgets get line from file pointer 

// fgetss get line from file pointer and strip HTML tags 

file read entire file into an array 

file_exists Check whether a file exists. 

// fileatime get last access time of file 

// filectime get inode change time of file 

// filegroup get file group 

// fileinode get file inode 

// filemtime get file modification time 

// fileowner get file owner 

// fileperms get file permissions 

// filesize get file size 

// filetype get file type 

// flock portable advisory file locking 

fopen open file or URL 



// fpassthm output all remaining data on a file pointer 

fputs write to a file pointer 

fread Binary- safe file read 

fseek seek on a file pointer 

ftell tell file pointer read/write position 

fwrite Binary-safe file write 

// set_file_buffer Sets file buffering on the given file pointer 

is_dir tells whether the filename is a directory 



is executable tells whether the filename is executable 



is_file tells whether the filename is a regular file 



is_link tells whether the filename is a symbolic link 



is readable tells whether the filename is readable 



is_writeable tells whether the filename is writeable 

// link Create a hard link 

// linkinfo Get information about a link 

mkdir make directory 

pclose close process file pointer 

popen open process file pointer 

readfile output a file 

readlink R eturn the target of a symbolic link 

rename rename a file 

rewind rewind the position of a file pointer 

rmdir remove directory 

// Stat give information about a file 

// Istat give information about a file or symbolic link 

symlink C reate a symbolic link 

// tempnam create unique file name 

// touch set modification time of file 

// umask changes the current umask 

unlink Delete a file 



Prev Home Next 

filepro_rowcount Up basename 



PHP Manual 

Prev Next 



getallheaders 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getallheaders ~ Fetch all HTTP request headers 

Description 

array getallheaders(void); 

This function returns an associative array of all the HTTP headers in the current request. 

Note: You can also get at the value of the common CGI variables by reading them 
from the environment, which works whether or not you are using PHP as an Apache 
module. Use phpinfoQ to see a list of all of the environment variables defined this 
way. 
Example 1. getallheaders() Example 

$headers = getallheaders () ; 

while (list ( $header, $value) = each ( $headers) ) { 

echo "$header: $value<br>\n" ; 
} 
This example will display all the request headers for the current request. 

Note: getallheadersO is currently only supported when PHP runs as an Apache 
module. 

Prev Home Next 

apache_note Ug virtual 



PHP Manual 

Prev Next 



. Arbitrary precision mathematics 
functions 



These functions are not suppc 

PHP Lite edition. 

Look at the functions manual-page to 

^^^ossibl^wo^araun^xists™ 




These functions are only available if PHP was configured with — enable-bcmath. 

Table of Contents 

// bcadd Add two arbitrary precision numbers. 

// bccomp Compare two arbitrary precision numbers. 

// bcdiv Divide two arbitrary precision numbers. 

// bcmod Get modulus of an arbitrary precision number. 

// bcmul Multiply two arbitrary precision number. 

// bcpow Raise an arbitrary precision number to another. 

// bcscale Set default scale parameter for all be math functions. 

// bcsqrt Get the square root of an arbitray precision number. 

// bcsub Subtract one arbitrary precision number from another. 

Prev Home Next 

virtual Ug bcadd 



PHP Manual 

Prev Next 



II. Apache-specific functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



Table of Contents 

// apache_lookup_uri Perform a partial request for the specified URI and return all info about it 
// apache_note Get and set apache request notes 
// getallheaders Fetch all HTTP request headers 
// virtual Perform an Apache sub-request 

Prev Home Next 

ada_rollback Up apache_lookup_uri 



PHP Manual 

Prev Next 



die 

die ~ Output a message and terminate the current script 

Description 

void die(string message); 

This language construct outputs a message and terminates parsing of the script. It does not return. 

Example 1. die example 

<?php 

$filename = '/path/to/data-file'; 

$file = f open ( $f ilename, 'r') 

or die "unable to open file ( $f ilename) " ; 
?> 



Prev Home Next 

defined Up eval 



PHP Manual 

Prev Next 



mssql_select_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_select_db ~ select MS SQL database 

Description 

i n t ms s ql_s e 1 e c t_db(string database_name, int Hnk_identifier); 

Returns: true on success, false on error 

mssql_select_db() sets the current active database on the server that's associated with the specified 
link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, 
the function will try to establish a link as if mssql_connect() was called, and use it. 

Every subsequent call to mssql_query() will be made on the active database. 

See also: mssql_connect() , mssql_pconnect() , and mssql_query() 

Prev Home Next 

mssql_result U^ Miscellaneous functions 



PHP Manual 

Prev Next 



connection_aborted 

connection_aborted ~ Returns true if client disconnected 

Description 

int connection_aborted(void ); 

Returns true if client disconnected. See the Connection Handling description in the Features chapter 
for a complete explanation. 

Prev Home Next 

Miscellaneous functions Up connection_status 



PHP Manual 

Prev Next 



connection_status 

connection_status ~ Returns connection status bitfield 

Description 

int connection_status(void ); 

Returns the connection status bitfield. See the Connection Handling description in the Features 
chapter for a complete explanation. 

Prev Home Next 

connection_aborted Up connection_timeout 



PHP Manual 

Prev Next 



connection_timeout 

connection_timeout ~ Return true if script timed out 

Description 

int connection_timeout(void ); 

Returns true if script timed out. See the Connection Handling description in tlie Features chapter for 
a complete explanation. 

Prev Home Next 

connection_status Up define 



PHP Manual 

Prev Next 



define 

define ~ Defines a named constant. 

Description 

int def ine(string name, mixed value, int [case_insensitive]); 
Defines a named constant, which is similar to a variable except: 

q Constants do not have a dollar sign '$' before them; 

q Constants may be accessed anywhere without regard to variable scoping rules; 

q Constants may not be redefined or undefined once they have been set; and 

q Constants may only evaluate to scalar values. 

The name of the constant is given by name; the value is given by value. 

The optional third parameter case_insensitive is also available. If the value 1 is given, then 
the constant will be defined case-insensitive. The default behaviour is case-sensitive; i.e. 
CONSTANT and Constant represent different values. 

Example 1. Defining Constants 

<?php 

define ("CONSTANT", "Hello world."); 

echo CONSTANT; // outputs "Hello world." 

?> 

defineO returns TRUE on success and FALSE if an error occurs. 
See also definedQ and the section on Constants . 

Prev Home Next 

connection_timeout Ug defined 



PHP Manual 

Prev Next 



defined 

defined ~ Checks whether a given named constant exists. 

Description 

int def ined(string name); 

Returns TRUE if the named constant given by name has been defined, false otherwise. 

See also defineQ and the section on Constants . 

Prev Home Next 

define U^ die 



PHP Manual 

Prev Next 



leak 

leak ~ Leak memory 

Description 

void leak(int bytes); 

LeakQ leaks the specified amount of memory. 

This is useful when debugging the memory manager, which automatically cleans up "leaked" 
memory when each request is completed. 

Prev Home Next 

iptcparse Up pack 



PHP Manual 

Prev Next 



pack 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



pack ~ pack data into binary string 

Description 

string pack(string format, mixed [args]...); 

Pack given arguments into binary string according to format. Returns binary string containing 
data. 

The idea to this function was taken from Perl and all formatting codes work the same as there. The 
format string consists of format codes followed by an optional repeater argument. The repeater 
argument can be either an integer value or * for repeating to the end of the input data. For a, A, h, H 
the repeat count specifies how many characters of one data argument are taken, for @ it is the 
absolute position where to put the next data, for everything else the repeat count specifies how 
many data arguments are consumed and packed into the resulting binary string. Currently 
implemented are 

q a NUL-padded string 

q A SPACE-padded string 

q h Hex string, low nibble first 

q H Hex string, high nibble first 

q c signed char 

q C unsigned char 

q s signed short (always 16 bit, machine byte order) 

q S unsigned short (always 16 bit, machine byte order) 

q n unsigned short (always 16 bit, big endian byte order) 

q V unsigned short (always 16 bit, little endian byte order) 

q i signed integer (machine dependant size and byte order) 



q I unsigned integer (machine dependant size and byte order) 

q 1 signed long (always 32 bit, machine byte order) 

q L unsigned long (always 32 bit, machine byte order) 

q N unsigned long (always 32 bit, big endian byte order) 

q V unsigned long (always 32 bit, little endian byte order) 

q f float (machine dependent size and representation) 

q d double (machine dependent size and representation) 

q xNULbyte 

q X Back up one byte 

q @ NUL-fill to absolute position 
Example 1. pack format string 

$binarydata = pack("nvc*", 0x1234, 0x5678, 65, 66); 

The resulting binary string will be 6 bytes long and contain the byte sequence 0x12, 0x34, 0x78, 
0x56, 0x41, 0x42. 

Note that the distinction between signed and unsigned values only affects the function unpackQ , 
where as function pack() gives the same result for signed and unsigned format codes. 

Also note that PHP internally stores integral values as signed values of a machine dependant size. If 
you give it an unsigned integral value too large to be stored that way it is converted to a double 
which often yields an undesired result. 

Prev Home Next 

leak Up register_shutdown_function 



PHP Manual 

Prev Next 



register_shutdown_function 

register_shutdown_function ~ Register a function for execution on shutdown. 

Description 

int register_shutdown_f unction(string func); 

Registers the function named by func to be executed when script processing is complete. 

Common Pitfalls: 

Since no output is allowed to the browser in this function, you will be unable to debug it using 
statements such as print or echo. 

Prev Home Next 

pack Up serialize 



PHP Manual 

Prev Next 



serialize 



Pu^uncnoin^io^uppotte^inn^^H 
i^HP Lite edition. ^^ 

J*ossible workaround not yet pub^^otaH 

serialize ~ generates a storable representation of a value 

Description 

string serialize(mixed value); 

serializeO returns a string containing a byte-stream representation of value that can be stored anywhere. 

This is useful for storing or passing PHP values around without losing their type and structure. 

To make the serialized string into a PHP value again, use unserializeQ . serializeO handles the types integer, 
double, string, array (multidimensional) and object (object properties will be serialized, but methods are 
lost). 

Example 1. serialize example 

// $session_data contains a multi-dimensional array with session 
// information for the current user. We use serialize () to store 
// it in a database at the end of the request. 

$conn = odbc_connect ( "webdb" , "php", "chicken"); 
$stmt = odbc_prepare ($conn, 

"UPDATE sessions SET data = ? WHERE id = ?"); 
$sqldata = array ( serialize ( $session_data) , $PHP_AUTH_USER) ; 
if ( ! odbc_execute ($stmt , &$sqldata) ) { 
$stmt = odbc_prepare ( $conn, 

"INSERT INTO sessions (id, data) VALUES (?, ?)"); 
if ( ! odbc_execute ( $stmt , &$sqldata) ) { 

/* Something went wrong. Bitch, whine and moan. */ 
} 
} 

Prev Home Next 

register_shutdown_function Up sleep 



PHP Manual 

Prev Next 



sleep 

sleep ~ Delay execution 

Description 



void sleep(int seconds); 

The sleep function delays program execution for the given number of seconds. 

See also usleepQ . 

Prev Home Next 

serialize Up uniqid 



PHP Manual 

Prev Next 



uniqid 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



uniqid ~ Generate a unique id. 

Description 

int uniqid(string prefix, boolean [leg]); 

uniqidO returns a prefixed unique identifier based on the current time in microseconds. The prefix 
can be useful for instance if you generate identifiers simultaneously on several hosts that might 
happen to generate the identifier at the same microsecond, prefix can be up to 1 14 characters 
long. 

If the optional 1 eg parameter is true, uniqid() will add additional "combined LCG" entropy at the 
end of the return value, which should make the results more unique. 

With an empty prefix, the returned string will be 13 characters long. If leg is true, it will be 23 
characters. 

Note: The 1 eg parameter is only available in PHP 4 and PHP 3.0. 13 and later. 

If you need a unique identifier or token and you intend to give out that token to the user via the 
network (i.e. session cookies), it is recommended that you use something along the lines of 

$token = md5 (uniqid ("")) ; // no random portion 

$better_token = md5 (uniqid (rand ())) ; // better, difficult to guess 

This will create a 32 character identifier (a 128 bit hex number) that is extremely difficult to 
predict. 

Prev Home Next 

sleep U^ unpack 



PHP Manual 

Prev Next 



unpack 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

unpack — unpack data from binary string 

Description 

array unpack(string format, string data); 

Unpack from binary string into array according to format. Returns array containing unpacked 
elements of binary string. 

Unpack works sUghtly different from Perl as the unpacked data is stored in an associative array. To 
accomplish this you have to name the different format codes and separate them by a slash /. 

Example 1. unpack format string 

$array = unpack ( "c2chars/nint" , $binarydata) ; 

The resulting array will contain the entries "charsl", "chars2" and "int". 
For an explanation of the format codes see also: packQ 

Note that PHP internally stores integral values as signed. If you unpack a large unsigned long and it 
is of the same size as PHP internally stored values the result will be a negative number even though 
unsigned unpacking was specified. 

Prev Home Next 

uniqid Ug unserialize 



PHP Manual 

Prev Next 



unserialize 



phis function is not supponedinth^^^B 
pHP Lite edition. ■ 

P'ossible workarouM|M|||||||>ublisli|dM 



unserialize — creates a PHP value from a stored representation 

Description 

mixed unserialize(string str); 

unserializeO takes a single serialized variable (see serializeQ ) and converts it back into a PHP value. The 
converted value is returned, and can be an integer, double, string, array or object. If an object was 
serialized, its methods are not preserved in the returned value. 

Example 1. unserialize example 

// Here, we use unserializeO to load session data from a database 
// into $session_data . This example complements the one described 
// with serialize () . 

$conn = odbc_connect ( "webdb" , "php", "chicken"); 

$stmt = odbc_prepare ($conn, "SELECT data FROM sessions WHERE id = ?"); 

$sqldata = array ($PHP_AUTH_USER) ; 

if ( ! odbc_execute ($stmt, &$sqldata) | | ! odbc_f etch_into ($stmt, &$tmp) ) { 

// if the execute or fetch fails, initialize to empty array 

$session_data = array (); 
} else { 

// we should now have the serialized data in $tmp[0] . 

$session_data = unserialize ($tmp [ 0] ) ; 

if ( ! is_array ($session_data) ) { 

// something went wrong, initialize to empty array 
$session_data = array (); 

} 
} 

Prev Home Next 

unpack U^ usleep 



PHP Manual 

Prev Next 



usieep 

usleep ~ Delay execution in microseconds 

Description 



void usleep(int micro_seconds); 

The sleep function delays program execution for the given number of micro_seconds. 

See also sleep () . 

Prev Home Next 

unserialize Up mSQL functions 



PHP Manual 

Prev Next 



GetlmageSize 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

GetlmageSize ~ get the size of a GIF, JPG or PNG image 

Description 

array getimagesize(string filename, array [imageinfo]); 

The GetlmageSizeQ function will determine the size of any GIF, JPG or PNG image file and 
return the dimensions along with the file type and a height/width text string to be used inside a 
normal HTML IMG tag. 

Returns an array with 4 elements. Index contains the width of the image in pixels. Index 1 
contains the height. Index 2 a flag indicating the type of the image. 1 = GIF, 2 = JPG, 3 = PNG. 
Index 3 is a text string with the correct "height=xxx width=xxx" string that can be used directly in 
an IMG tag. 

Example 1. GetlmageSize 

<?php $size = GetlmageSize ( "img/f lag. jpg" ) ; ?> 
<IMG SRC="img/flag. jpg" <?php echo $size[3]; ?>> 

The optional imageinfo parameter allows you to extract some extended information from the 
image file. Currently this will return the diffrent JPG APP markers in an associative Array. Some 
Programs use these APP markers to embedd text information in images. A very common one in to 
embed IPTC http://www.xe.net/iptc/ information in the APP 13 marker. You can use the iptcparseQ 
function to parse the binary APP 13 marker into something readable. 
Example 2. GetlmageSize returning IPTC 

<?php 

$size = GetlmageSize ( "testimg. jpg" , &$info) ; 
if (isset ($info["APP13"] ) ) { 

$iptc = iptcparse ($info ["APP13"] ) ; 

var_dump ($iptc) ; 

} 
?> 

Note: This function does not require the GD image library. 



Prev Home Next 

Image functions U^ ImageArc 



PHP Manual 

Prev Next 



ldap_error 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ldap_error ~ Return the LDAP error message of the last LDAP command 

Description 

string ldap_error(int Hnk_id); 

returns string error message. 

This function returns the string error message explaining the error generated by the last LDAP 
command for the given link identifier. While LDAP errno numbers are standardized, different 
libraries return different or even localized textual error messages. Never check for a specific error 
message text, but always use an error number to check. 

Unless you lower your warning level in your php3 . ini sufficiently or prefix your LDAP 
commands with @ (at) characters to suppress warning output, the errors generated will also show up 
in your HTML output. 

see also ldap_err2str() and ldap_errno() . 

Prev Home Next 

ldap_errno Up Mail functions 



PHP Manual 

Prev Next 



Abs 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Abs ~ absolute value 

Description 

mixed abs (mixed number) ; 

Returns the absolute value of number. If the argument number is float, return type is also float, 
otherwise it is int. 

Prev Home Next 

Mathematical functions Up Acos 



PHP Manual 

Prev Next 



Acos 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Acos ~ arc cosine 

Description 

float a cos (float arg); 

Returns the arc cosine of arg in radians. 

See also asinQ and atanQ . 

Prev Home Next 

Abs U£ Asin 



PHP Manual 

Prev Next 



Asin 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Asin ~ arc sine 

Description 

float asin(float arg); 

Returns the arc sine of arg in radians. 

See also acosQ and atanQ . 

Prev Home Next 

Acos U^ Atan 



PHP Manual 

Prev Next 



Atari 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Atan ~ arc tangent 

Description 

float atan(float arg); 

Returns the arc tangent of arg in radians. 

See also acosQ and atan(). 

Prev Home Next 

Asin U^ Atan2 



PHP Manual 

Prev Next 



Atan2 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Atan2 — arc tangent of two variables 

Description 

float atan2(floaty, float x); 

This function calculates the arc tangent of the two variables x and y. It is similar to calculating the 
arc tangent of y / x, except that the signs of both arguments are used to determine the quadrant of 
the result. 

The function returns the result in radians, which is between -PI and PI (inclusive). 

See also acosQ and atanQ . 

Prev Home Next 

Atan Up base_convert 



PHP Manual 

Prev Next 



base_convert 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

base_convert ~ convert a number between arbitrary bases 

Description 

strin base_convert(string number, int frombase, int tobase); 

Returns a string containing number represented in base tobase. The base in which number is 
given is specified in frombase. Both frombase and tobase have to be between 2 and 36, 
inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with 
a meaning 10, b meaning 11 and z meaning 36. 

Example 1. base_convert() 

$binary = base_convert ($hexadecimal, 16, 2); 

Prev Home Next 

Atan2 Up BinDec 



PHP Manual 

Prev Next 



BinDec 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



BinDec ~ binary to decimal 

Description 

int bindec(string binary_string); 

Returns the decimal equivalent of the binary number represented by the binary_string argument. 

OctDec converts a binary number to a decimal number. The largest number that can be converted is 
31 bits of I's or 2147483647 in decimal. 

See also the decbinQ function. 

Prev Home Next 

base_convert Up Ceil 



PHP Manual 

Prev Next 



Ceil 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Ceil ~ round fractions up 

Description 

int ceil (float number); 

Returns the next highest integer value from number. Using ceil() on integers is absolutely a waste 
of time. 

NOTE: PHP/FI 2's ceilQ returned a float. Use: $new = (double) ceil ($number) ; to get 
the old behaviour. 

See also floorQ and roundQ . 

Prev Home Next 

BinDec Ug Cos 



PHP Manual 

Prev Next 



Cos 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Cos ~ cosine 

Description 

float CO s (float arg); 

Returns the cosine of arg in radians. 

See also sinQ and tan() . 

Prev Home Next 

Ceil UE DecBin 



PHP Manual 

Prev Next 



DecBin 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



DecBin ~ decimal to binary 

Description 

string decbin(int number); 

Returns a string containing a binary representation of the given number argument. The largest 
number that can be converted is 2147483647 in decimal resulting to a string of 31 I's. 

See also the bindecQ function. 

Prev Home Next 

Cos Ug DecHex 



PHP Manual 

Prev Next 



DecHex 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



DecHex ~ decimal to hexadecimal 

Description 

string dechex(int number); 

Returns a string containing a hexadecimal representation of the given number argument. The largest 
number that can be converted is 2147483647 in decimal resulting to "7fffffff". 

See also the hexdecQ function. 

Prev Home Next 

DecBin U^ DecOct 



PHP Manual 

Prev Next 



DecOct 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



DecOct ~ decimal to octal 

Description 

string decoct(int number); 

Returns a string containing an octal representation of the given number argument. The largest 
number that can be converted is 2147483647 in decimal resulting to "17777777777". See also 
octdecQ . 

Prev Home Next 

DecHex Up Exp 



PHP Manual 

Prev Next 



Exp 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Exp ~ e to the power of... 

Description 

float e xp (float arg); 

Returns e raised to the power of arg. 

See also powQ . 

Prev Home Next 

DecOct U^ Floor 



PHP Manual 

Prev Next 



Floor 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Floor ~ round fractions down 

Description 

int floor (float number) ; 

Returns the next lowest integer value from number. Using floor() on integers is absolutely a waste 
of time. 

NOTE: PHP/FI 2's floorO returned a float. Use: $new = (double) f loor ($number) ; to get 
the old behaviour. 

See also ceilQ and roundQ . 

Prev Home Next 

Exp U^ getrandmax 



PHP Manual 

Prev Next 



getrandmax 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getrandmax — show largest possible random value 

Description 

int getrandmax(void ); 

Returns the maximum value that can be returned by a call to randQ . 

See also randQ , srandQ mt_rand() , mt_srand() and mt_getrandmax() . 

Prev Home Next 

Floor Ug HexDec 



PHP Manual 

Prev Next 



Hex Dec 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



HexDec ~ hexadecimal to decimal 

Description 

int hexdec(string hex_string); 

Returns the decimal equivalent of the hexadecimal number represented by the hex_string argument. 
HexDec converts a hexadecimal string to a decimal number. The largest number that can be 
converted is 7fffffff or 2147483647 in decimal. 

See also the dechexQ function. 

Prev Home Next 

getrandmax Up Log 



PHP Manual 

Prev Next 



Log 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Log ~ natural logarithm 

Description 

float log(float arg); 

Returns the natural logarithm of arg. 

Prev Home Next 

HexDec Up Log 10 



PHP Manual 

Prev Next 



Log10 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Log 10 ~ base- 10 logarithm 

Description 

float logl (float arg); 

Returns the base- 10 logarithm of arg. 

Prev Home Next 

Log Up max 



PHP Manual 

Prev Next 



max 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



max ~ find highest value 

Description 

mixed max(mixed argl, mixed arg2, mixed argn); 

max() returns the numerically highest of the parameter values. 

If the first parameter is an array, max() returns the highest value in that array. If the first parameter 
is an integer, string or double, you need at least two parameters and max() returns the biggest of 
these values. You can compare an unlimited number of values. 

If one or more of the values is a double, all the values will be treated as doubles, and a double is 
returned. If none of the values is a double, all of them will be treated as integers, and an integer is 
returned. 

Prev Home Next 

Log 10 Ug min 



PHP Manual 

Prev Next 



mm 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



min ~ find lowest value 

Description 

mixed min(mixed argl, mixed arg2, mixed argn); 

min() returns the numerically lowest of the parameter values. 

If the first parameter is an array, min() returns the lowest value in that array. If the first parameter is 
an integer, string or double, you need at least two parameters and min() returns the lowest of these 
values. You can compare an unlimited number of values. 

If one or more of the values is a double, all the values will be treated as doubles, and a double is 
returned. If none of the values is a double, all of them will be treated as integers, and an integer is 
returned. 

Prev Home Next 

max U^ mt_rand 



PHP Manual 

Prev Next 



mt rand 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mt_rand ~ generate a better random value 

Description 

i n t mt _r a n d( [int min] , [int max] ) ; 

Many random number generators of older libcs have dubious or unknown characteristics and are 
slow. By default, PHP uses the libc random number generator with the randQ function. mt_rand() 
function is a drop-in replacement for this. It uses a random number generator with known 
characteristics, the Mersenne Twister, which will produce random numbers that should be suitable 
for cryptographic purposes and is four times faster than what the average libc provides. The 
Homepage of the Mersenne Twister can be found at 

http://www.math.keio.ac.ip/~matumoto/emt.html , and an optimized version of the MT source is 
available from http://www.scp.syr.edu/~marc/hawk/twister.html . 

If called without the optional min,max arguments mt_rand() returns a pseudo-random value 
between and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for 
example, use mt_rand(5,15). 

Remember to seed the random number generator before use with mt_srand() . 
See also mt_srand() , mt_getrandmax() , srandQ , randQ and getrandmaxQ . 

Prev Home Next 

min Up mt_srand 



PHP Manual 

Prev Next 



mt srand 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mt_srand ~ seed the better random number generator 

Description 



void mt_srand(int seed); 

Seeds the random number generator with seed. 

// seed with microseconds since last "whole" second 
mt_srand ( (double) microtime () *1000000) ; 
$randval = mt_rand ( ) ; 

See also mt_rand() , mt_getrandmax() , srandQ , randQ and getrandmaxQ . 

Prev Home Next 

mt_rand Up mt_getrandmax 



PHP Manual 

Prev Next 



mt_getrandmax 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mt_getrandmax ~ show largest possible random value 

Description 

int mt_getrandmax(void ); 

Returns the maximum value that can be returned by a call to mt_rand() . 

See also mt_rand() , mt_srand() randQ , srandQ and getrandmaxQ . 

Prev Home Next 

mt_srand Ug number_format 



PHP Manual 

Prev Next 



number_format 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

number_format ~ format a number with grouped thousands 

Description 

string number_f or mat (float number, int decimals, string dec_point, string thousands_sep); 

number_format() returns a formatted version of number. This function accepts either one, two or 
four parameters (not three): 

If only one parameter is given, number will be formatted without decimals, but with a comma (",") 
between every group of thousands. 

If two parameters are given, number will be formatted with decimals decimals with a dot (".") 
in front, and a comma (",") between every group of thousands. 

If all four parameters are given, number will be formatted with decimals decimals, 
dec_point instead of a dot (".") before the decimals and thousands_sep instead of a comma 
(",") between every group of thousands. 

Prev Home Next 

mt_getrandmax Up OctDec 



PHP Manual 

Prev Next 



OctDec 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



OctDec ~ octal to decimal 

Description 

int octdec(string octal_string); 

Returns the decimal equivalent of the octal number represented by the octal_string argument. 
OctDec converts an octal string to a decimal number. The largest number that can be converted is 
17777777777 or 2147483647 in decimal. 

See also decoctQ . 

Prev Home Next 

number_format Up pi 



PHP Manual 

Prev Next 



pi 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



pi ~ get value of pi 

Description 

double pi(void); 

Returns an approximation of pi. 

Prev Home Next 

OctDec Up pow 



PHP Manual 

Prev Next 



pow 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



pow ~ exponential expression 

Description 

float pow(float base, float exp); 
Returns base raised to the power of exp. 
See also expQ . 

Prev Home Next 

pi U^ rand 



PHP Manual 

Prev Next 



rand 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



rand ~ generate a random value 

Description 

int rand( [int min] , [int max] ) ; 

If called without the optional min,max arguments rand() returns a pseudo-random value between 
and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use 
rand(5,15). 

Remember to seed the random number generator before use with srandQ . 

See also srandQ , getrandmaxQ , mt_rand() , mt_srand() and mt_getrandmax() . 

Prev Home Next 

pow Up round 



PHP Manual 

Prev Next 



round 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



round ~ Rounds a float. 

Description 

double round(double val); 

Returns the rounded value of val. 

$foo = round ( 3.4 ); // $foo ==3.0 
$foo = round ( 3.5 ); // $foo ==4.0 
$foo = round ( 3.6 ); // $foo ==4.0 

See also ceilQ and floor () . 

Prev Home Next 

rand Up Sin 



PHP Manual 

Prev Next 



Sin 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Sin ~ sine 

Description 

float sin(float arg); 
Returns the sine of arg in radians. 
See also cosQ and tan() . 

Prev Home Next 

round U^ Sqrt 



PHP Manual 

Prev Next 



Sqrt 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Sqrt ~ square root 

Description 

float s qrt (float arg); 
Returns the square root of arg. 

Prev Home Next 

Sin Up srand 



PHP Manual 

Prev Next 



srand 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

srand ~ seed the random number generator 

Description 



void srand(int seed); 

Seeds the random number generator with seed. 

// seed with microseconds since last "whole" second 
srand ( (double) microtime () *1000000) ; 
$randval = rand ( ) ; 

See also randQ , getrandmaxQ , mt_rand() , mt_srand() and mt_getrandmax() . 

Prev Home Next 

Sqrt Up Tan 



PHP Manual 

Prev Next 



Tan 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Tan ~ tangent 

Description 

float tan(float arg); 

Returns the tangent of arg in radians. 

See also sin() and cos(). 



Prev Home Next 

srand U^ MCAL functions 



PHP Manual 

Prev Next 



recode_string 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

recode_string — Recode a string according to a recode request. 

Description 

string recode_string(string request, string string); 

Recode the string string according to the recode request request. Returns FALSE, if unable to 
comply, TRUE otherwise. 

A simple recode request may be "latl..iso646-de". See also the GNU Recode documentation of 
your installation for detailed instructions about recode requests. 

Prev Home Next 

GNU Recode functions Up recode_file 



PHP Manual 

Prev Next 



recode file 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



recode_file ~ Recode from file to file according to recode request. 

Description 

bool recode_file (int input, int output) ; 

Recode the file referenced by file handle input into the file referenced by file handle output 
according to the recode request request. Returns FALSE, if unable to comply, TRUE otherwise. 

This function does not currently process filehandles referencing remote files (URLs). Both 
filehandles must refer to local files. 

Prev Home Next 

recode_string Up Regular expression functions 



PHP Manual 

Prev Next 



unset 

unset ~ Unset a given variable 

Description 

int unset (mixed var); 

unsetO destroys the specified variable and returns true. 

Example 1. unset() example 

unset ( $foo ) ; 

unset ( $bar['quux'] ); 

See also issetQ and emptyQ . 

Prev Home Next 

strval Up Vmailmgr functions 



PHP Manual 

Prev Next 



pclose 

pclose ~ close process file pointer 

Description 



int pclose(int fp); 

Closes a file pointer to a pipe opened by popenQ . 

The file pointer must be valid, and must have been returned by a successful call to popenQ . 

Returns the termination status of the process that was run. 

See also popenQ . 

Prev Home Next 

mkdir Up popen 



PHP Manual 

Prev Next 



fgets 



fgets ~ get line from file pointer 

Description 

string f gets (int fp, int length); 

Returns a string of up to length - 1 bytes read from the file pointed to by fp. Reading ends when 
length - 1 bytes have been read, on a newline (which is included in the return value), or on EOF 
(whichever comes first). 

If an error occurs, returns false. 

Common Pitfalls: 

People used to the 'C semantics of fgets should note the difference in how EOF is returned. 

The file pointer must be valid, and must point to a file successfully opened by fopenQ , popenQ , or 
fsockopenQ . 

A simple example follows: 

Example 1. Reading a file line by line 

$fd = f open ( " /tmp/inputf ile . txt " , "r"); 
while (!feof($fd)) { 

$buffer = fgets ($fd, 4096); 

echo $buffer; 

} 

f close ($f d) ; 

See also freadQ , fopenQ , popenQ , fgetcQ , and fsockopenQ . 

Prev Home Next 

fgetcsv Up fgetss 



PHP Manual 

Prev Next 



fgetss 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fgetss ~ get Hne from file pointer and strip HTML tags 

Description 

string f getss(int fp, int length, string [allowable_tags]); 

Identical to fgetsQ , except that fgetss attempts to strip any HTML and PHP tags from the text it 
reads. 

You can use the optional third parameter to specify tags which should not be stripped. 

Note: allowable_tags was added in PHP 3.0.13, PHP4B3. 

See also fgetsQ , fopenQ , fsockopenQ , popenQ , and strip_tags() . 

Prev Home Next 

fgets U^ file 



PHP Manual 

Prev Next 



fputs 



fputs ~ write to a file pointer 

Description 

int fputs(int fp, string str, int [length]); 

fputsO is an alias to fwriteQ , and is identical in every way. Note that the length parameter is 
optional and if not specified the entire string will be written. 

Prev Home Next 

fpassthm Up fread 



Prev 



PHP Manual 

Chapter 10. Operators 



Next 



Comparison Operators 

Comparison operators, as their name implies, allow you to compare two values. 
Table 10-3. Comparison Operators 



example 


name 


result 


$a == $b 


Equal 


True if $a is equal to $b. 


$a $b 


Identical 


True if $a is equal to $b, and they are of the same type. (PHP4 
only) 


$a != $b 


Not equal 


True if $a is not equal to $b. 


$a<$b 


Less than 


True if $a is strictly less than $b. 


$a>$b 


Greater than 


True if $a is strictly greater than $b. 


$a <= $b 


Less than or equal to 


True if $a is less than or equal to $b. 


$a >= $b 


Greater than or equal to 


True if $a is greater than or equal to $b. 



Another conditional operator is the "?:" (or trinary) operator, which operates as in C and many other 
languages. 

(exprl) ? (expr2) : (exprS); 

This expression evaluates to expr2 if exprl evaluates to true, and exprS if exprl evaluates to 
false. 



Prev 

Bitwise Operators 



Home 



Next 
Execution Operators 



Prev 



PHP Manual 

Chapter 10. Operators 



Next 



Incrementing/Decrementing Operators 

PHP supports C-style pre- and post-increment and decrement operators. 
Table 10-4. Increment/decrement Operators 



example 


name 


effect 


++$a 


Pre-increment 


Increments $a by one, then returns $a. 


$a++ 


Post-increment 


Returns $a, then increments $a by one. 


~$a 


Pre-decrement 


Decrements $a by one, then returns $a. 


$a~ 


Post-decrement 


Returns $a, then decrements $a by one. 



Here's a simple example script: 

<?php 

echo "<h3>Postincrement</h3>" ; 

$a = 5; 

echo "Should be 5 : " . $a++ . "<br>\n"; 

echo "Should be 6: " . $a . "<br>\n"; 

echo "<h3>Preincrement</h3>" ; 

$a = 5; 

echo "Should be 6 : " . ++$a . "<br>\n"; 

echo "Should be 6: " . $a . "<br>\n"; 

echo "<h3>Postdecrement</h3>" ; 

$a = 5; 

echo "Should be 5: " . $a — . "<br>\n"; 

echo "Should be 4 : " . $a . "<br>\n"; 

echo "<h3>Predecrement</h3>" ; 

$a = 5; 

echo "Should be 4 : " . — $a . "<br>\n"; 

echo "Should be 4 : " . $a . "<br>\n"; 

?> 



Prev 

Execution Operators 



Home 



Next 
Logical Operators 



PHP Manual 

Prev Next 



pgjty 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



pg_tty ~ Returns the tty name 

Description 

string p g_t t y (int connection_id) ; 

pg_tty() will return the tty name that server side debugging output is sent to on the given 
PostgreSQL connection identifier. 

Prev Home Next 

pg_Result Up Program Execution functions 



PHP Manual 

Prev Next 



rewinddir 

rewinddir ~ rewind directory handle 

Description 

void rewinddir(int dir_handle); 

Resets the directory stream indicated by dir_handle to the beginning of the directory. 

Prev Home Next 

readdir Ug Dynamic Loading functions 



PHP Manual 

Prev Next 



imap_status 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_status ~ This function returns status information on a mailbox other than the current one. 

Description 

ob j ect imap_st atus(int imap_stream, string mailbox, int options); 

This function returns an object containing status information. Valid flags are: 

q SA_MESSAGES - set status->messages to the number of messages in the mailbox 

q S A_RECENT - set status->recent to the number of recent messages in the mailbox 

q S A_UNSEEN - set status->unseen to the number of unseen (new) messages in the mailbox 

q SA_UIDNEXT - set status->uidnext to the next uid to be used in the mailbox 

q SA_UID VALIDITY - set status->uidvalidity to a constant that changes when uids for the 
mailbox may no longer be valid 

q S A_ALL - set all of the above 

status->flags is also set, which contains a bitmask which can be checked against any of the above 
constants. 

Prev Home Next 

imap_alerts Up Informix functions 



PHP Manual 

Prev Next 



ifx_query 






iThis function is not supported in 
PHP Lite edition, 
tossibl^wo^aroun^io^et 

ifx_query ~ Send Informix query 

Description 

int if x_query (string query, int [link_identifier] , int [cursor_type] , mixed [blobidarray] ); 

Returns: A positive Informix result identifier on success, or false on error. 

An integer "result_id" used by other functions to retrieve the query results. Sets "affected_rows" for 
retrieval by the ifx_affected_rows() function. 

ifx_query() sends a query to the currently active database on the server that's associated with the 
specified link identifier. If the link identifier isn't specified, the last opened link is assumed. If no link 
is open, the function tries to establish a link as if ifx_connect() was called, and use it. 

Executes query on connection conn_id. For "select-type" queries a cursor is declared and opened. 
The optional cursor_type parameter allows you to make this a "scroll" and/or "hold" cursor. It's a 
mask and can be either IFX_SCROLL, IFX_HOLD, or both or'ed together. Non-select queries are 
"execute immediate". 

For either query type the number of (estimated or real) affected rows is saved for retrieval by 
ifx_affected_rows() . 

If you have BLOB (BYTE or TEXT) columns in an update query, you can add a bl obi darray 
parameter containing the corresponding "blob ids", and you should replace those columns with a "?" 
in the query text. 

If the contents of the TEXT (or BYTE) column allow it, you can also use "ifx_textasvarchar(l)" and 
"ifx_byteasvarchar(l)". This allows you to treat TEXT (or BYTE) columns just as if they were 
ordinary (but long) VARCHAR columns for select queries, and you don't need to bother with blob 
id's. 

With ifx_textasvarchar(0) or ifx_byteasvarchar(0) (the default situation), select queries will return 
BLOB columns as blob id's (integer value). You can get the value of the blob as a string or file with 
the blob functions (see below). 

See also: ifx_connect(). 



Example 1. Show all rows of the "orders" table as a html table 

ifx_textasvarchar (1) ; // use "text mode" for blobs 
$res_id = if x_query ( "select * from orders", $conn_id) ; 
if ( ! $res_id) { 

printf ( "Can ' t select orders : %s\n<br>%s<br>\n" , if x_error ( ) ) ; 

if x_errormsg ( ) ; 

die; 

} 

ifx_htmltbl_result ($res_id, "border=\" 1\" " ) ; 
if x_f ree_result ($res_id) ; 

Example 2. Insert some values into the "catalog" table 

// create blob id's for a byte and text column 
$textid = ifx_create_blob (0, 0, "Text column in memory"); 
$byteid = ifx_create_blob ( 1, 0, "Byte column in memory"); 

// store blob id's in a blobid array 
$blobidarray [ ] = $textid; 
$blobidarray [ ] = $byteid; 

// launch query 
$query = "insert into catalog (stock_num, manu_code, " . 

"cat_descr, cat_picture) values ( 1, ' HRO ',?,?)"; 
$res_id = ifx_query ($query, $conn_id, $blobidarray) ; 
if ( ! $res_id) { 
. . . error . . . 

} 

// free result id 
if x_f ree_result ($res_id) ; 



Prev Home Next 

ifx_close Up ifx_prepare 



PHP Manual 

Prev Next 



ifx_prepare 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_prepare ~ Prepare an SQL-statement for execution 

Description 

int if x_prepare(string query, int conn_id, int [cursor_def], mixed blobidarray); 

Returns a integer result_id for use by ifx_do() . Sets affected_rows for retrieval by the 
ifx_affected_rows() function. 

Prepares query on connection conn_id. For "select-type" queries a cursor is declared and 
opened. The optional cursor_type parameter allows you to make this a "scroll" and/or "hold" 
cursor. It's a mask and can be either IFX_SCROLL, IFX_HOLD, or both or'ed together. 

For either query type the estimated number of affected rows is saved for retrieval by 
ifx_affected_rows() . 

If you have BLOB (BYTE or TEXT) columns in the query, you can add a blobidarray 
parameter containing the corresponding "blob ids", and you should replace those columns with a 
"?" in the query text. 

If the contents of the TEXT (or BYTE) column allow it, you can also use "ifx_textasvarchar(l)" 
and "ifx_byteasvarchar(l)". This allows you to treat TEXT (or BYTE) columns just as if they were 
ordinary (but long) VARCHAR columns for select queries, and you don't need to bother with blob 
id's. 

With ifx_textasvarchar(0) or ifx_byteasvarchar(0) (the default situation), select queries will return 
BLOB columns as blob id's (integer value). You can get the value of the blob as a string or file with 
the blob functions (see below). 

See also: ifx_do() . 

Prev Home Next 

ifx_query Up ifx_do 



PHP Manual 

Prev Next 



ifx_do 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_do ~ Execute a previously prepared SQL- statement 

Description 

int i f x_do(int result_id); 

Returns TRUE on success, FALSE on error. 

Executes a previously prepared query or opens a cursor for it. 

Does NOT free result_id on error. 

Also sets the real number of ifx_affected_rows() for non-select statements for retrieval by 
ifx_affected_rows() 

See also: ifx_prepare() . There is a example. 

Prev Home Next 

ifx_prepare Up ifx_error 



PHP Manual 

Prev Next 



ifx_error 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_error ~ Returns error code of last Informix call 

Description 

string if x_error(void); 

The Informix error codes (SQLSTATE & SQLCODE) formatted as follows : 

X [SQLSTATE = aa bbb SQLCODE=cccc] 

where x = space : no error 

E : error 

N : no more data 

W : warning 

? : undefined 

If the "x" character is anything other than space, SQLSTATE and SQLCODE describe the error in 
more detail. 

See the Informix manual for the description of SQLSTATE and SQLCODE 

Returns in a string one character describing the general results of a statement and both SQLSTATE 
and SQLCODE associated with the most recent SQL statement executed. The format of the string is 
"(char) [SQLSTATE=(two digits) (three digits) SQLCODE=(one digit)]". The first character can be 
' ' (space) (success), 'W (the statement caused some warning), 'E' (an error happened when 
executing the statement) or 'N' (the statement didn't return any data). 

See also: ifx_errormsg() 

Prev Home Next 

ifx_do Up ifx_errormsg 



PHP Manual 

Prev Next 



ifx_errormsg 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_errormsg ~ Returns error message of last Informix call 

Description 

string if x_errormsg(int [errorcode]); 

Returns the Informix error message associated with the most recent Informix error, or, when the 
optional "errorcode" param is present, the error message corresponding to "errorcode". 

See also: ifx_error() 

print f ( "%s\n<br>" , if x_errormsg (-201 ) ) ; 

Prev Home Next 

ifx_error Ug ifx_affected_rows 



PHP Manual 

Prev Next 



i f x_af f ected_ro ws 

■"his function is not supported in t^^^H 
Jh? Lite edition. ^M 

ifx_affected_rows — Get number of rows affected by a query 

Description 

int ifx_af fected_rows(intresult_id); 

re s ui t_ id is a valid result id returned by ifx_query() or ifx_prepare() . 

Returns the number of rows affected by a query associated with result_id. 

For inserts, updates and deletes the number is the real number (sqlerrd[2]) of affected rows. For selects it is an 
estimate (sqlerrd[0]). Don't rely on it. 

Useful after ifx_prepare() to limit queries to reasonable result sets. 

See also: ifx_num_rows() 
Example 1. Informix affected rows 

$rid = ifx_prepare ("select * from emp where name like " . $name, $connid) ; 
if (! $rid) { 

. . . error . . . 
} 

$rowcount = if x_af f ected_rows ($rid); 
if ($rowcount > 1000) { 

printf ("Too many rows in result set (%d)\n<br>", $rowcount); 

die ("Please restrict your query<br>\n" ) ; 
} 

Prev Home Next 

ifx_errormsg Up ifx_getsqlca 



PHP Manual 

Prev Next 



ifx_getsqlca 



m 

PHP Lite edition. 

Possible workaround not yet published 



I 



ifx_getsqlca -- Get the contents of sqlca.sqlerrd[0..5] after a query 

Description 

array if x_getsqlca(int result_id); 

resul t_i d is a valid result id returned by ifx_query() or ifx_prepare() . 

Returns a pseudo-row (assiociative arry) with sqlca.sqlerrd[0] to sqlca.sqlerrd[5] after the query associated with 

result_id. 

For inserts, updates and deletes the values returned are those as set by the server after executing the query. This gives access 
to the number of affected rows and the serial insert value. For selects the values are those saved after the prepare statement. 
This gives access to the estimated number of affected rows. The use of this function saves the overhead of executing a 
"select dbinfo('sqlca.sqlerrdx')" query, as it retrieves the values that were saved by the ifx driver at the appropriate moment. 

Example 1. Retrieve Informix sqlca.sqlerrd[x] values 

/* assume the first column of 'sometable' is a serial */ 

$qid = if x_query (" insert into sometable values (0, '2nd column', 'another column' ", 

$connid) ; 

if (! $qid) { 

. . . error . . . 

} 

$sqlca = ifx_getsqlca ($qid); 

$serial_value = $sqlca [ " sqlerrdl " ] ; 

echo "The serial value of the inserted row is : " . $serial_value<br>\n" ; 

Prev Home Next 

ifx_affected_rows Up ifx_fetch_row 



PHP Manual 

Prev Next 



ifx_fetch_row 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_fetch_row ~ Get row as enumerated array 

Description 

array if x_f etch_row(int result_id, mixed [position] ); 

Returns an associative array that corresponds to the fetched row, or false if there are no more rows. 

Blob columns are returned as integer blob id values for use in ifx_get_blob() unless you have used 
ifx_textasvarchar(l) or ifx_byteasvarchar(l), in which case blobs are returned as string values. 
Returns FALSE on error 

result_id is a valid resultid returned by ifx_query() or ifx_prepare() (select type queries 
only!). 

[position] is an optional parameter for a "fetch" operation on "scroll" cursors: "NEXT", 
"PREVIOUS", "CURRENT", "FIRST", "LAST" or a number. If you specify a number, an 
"absolute" row fetch is executed. This parameter is optional, and only valid for scrollcursors. 

ifx_fetch_row() fetches one row of data from the result associated with the specified result 
identifier. The row is returned as an array. Each result column is stored in an array offset, starting at 
offset 0. 

Subsequent call to ifx_fetch_row() would return the next row in the result set, or false if there are 
no more rows. 



Example 1. Informix fetch rows 

$rid = ifx_prepare ("select * from emp where name like " . $name, 

$connid, IFX_SCROLL) ; 
if (! $rid) { 

. . . error . . . 

} 

$rowcount = if x_af f ected_rows ( $rid) ; 

if ($rowcount > 1000) { 

printf ("Too many rows in result set (%d)\n<br>", $rowcount) ; 

die ("Please restrict your query<br>\n" ) ; 

} 

if (! ifx_do ($rid)) { 
. . . error . . . 

} 

$row = ifx_fetch_row ($rid, "NEXT"); 

while (is_array ($row) ) { 

for (reset ($row) ; $f ieldname=key ($row) ; next($row)) { 

$fieldvalue = $row [$f ieldname] ; 

printf ("%s = %s,", $fieldname, $fieldvalue) ; 

} 

printf ("\n<br>") ; 

$row = ifx_fetch_row ($rid, "NEXT"); 

} 

if x_f ree_result ($rid); 



Prev Home Next 

ifx_getsqlca U^ ifx_htmltbl_result 



PHP Manual 

Prev Next 



ifx_htmltbl_result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_htmltbl_result ~ Formats all rows of a query into a HTML table 

Description 

int ifx_htmltbl_result(intresult_id, string [html_table_options]); 

Returns the number of rows fetched or FALSE on error. 

Formats all rows of the resul t_ id query into a html table. The optional second argument is a 
string of <table> tag options 

Example 1. Informix results as HTML table 

$rid = ifx_prepare ("select * from emp where name like " . $name, 

$connid, IFX_SCROLL) ; 
if (! $rid) { 

. . . error . . . 

} 

$rowcount = if x_af f ected_rows ($rid); 

if ($rowcount > 1000) { 

printf ("Too many rows in result set (%d)\n<br>", $rowcount) ; 

die ("Please restrict your query<br>\n" ) ; 

} 

if (! ifx_do($rid) { 

. . . error . . . 
} 

ifx_htmltbl_result ($rid, "border=\ "2\ " " ) ; 
if x_f ree_result ($rid) ; 

Prev Home Next 

ifx_fetch_row Ug ifx_fieldtypes 



PHP Manual 

Prev Next 



ifx_fieldtypes 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_fieldtypes ~ List of Informix SQL fields 

Description 

array if x_f ieldtypes(int result_id); 



Returns an associative array with fieldnames as key and the SQL fieldtypes as data for query with 
result_id. Returns FALSE on error. 

Example 1. Fielnames and SQL fieldtypes 

$types = if x_f ieldtypes ($resultid); 
if (! isset ($types)) { 
. . . error . . . 

} 

for ($i = 0; $i < count ( $types) ; $i++) { 

$fname = key($types); 

printf("%s : \t type = %s\n", $fname, $types [$f name] ) ; 

next ($types) ; 
} 



Prev Home Next 

ifx_htmltbl_result Up ifx_fieldproperties 



PHP Manual 

Prev Next 



if x_field properties 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_fieldproperties ~ List of SQL fieldproperties 

Description 

array if x_f ieldproperties(int result_id); 

Returns an associative array with fieldnames as key and the SQL fieldproperties as data for a query 
with result_id. Returns FALSE on error. 

Returns the Informix SQL fieldproperies of every field in the query as an associative array. 
Properties are encoded as: "SQLTYPE;length;precision;scale;ISNULLABLE" where SQLTYPE = 
the Informix type like "SQLVCHAR" etc. and ISNULLABLE = "Y" or "N". 

Example 1. Informix SQL fieldproperties 

$properties = if x_f ieldtypes ($resultid); 
if (! isset ( $properties) ) { 
. . . error . . . 

} 

for ($i = 0; $i < count ( $properties) ; $i++) { 

$fname = key ( $properties) ; 

printf ("%s:\t type = %s\n", $fname, $properties [ $f name] ) ; 

next ($properties) ; 
} 



Prev Home Next 

ifx_fieldtypes U^ ifx_num_fields 



PHP Manual 

Prev Next 



ifx_num_fields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_num_fields — Returns the number of columns in the query 

Description 

int if x_num_f ields(int result_id); 

Returns the number of columns in query for result_id or FALSE on error 

After preparing or executing a query, this call gives you the number of columns in the query. 

Prev Home Next 

ifx_fieldproperties U^ ifx_num_rows 



PHP Manual 

Prev Next 



ifx num rows 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_num_rows ~ Count the rows already fetched a query 

Description 

int if x_num_rows(int result_id); 

Gives the number of rows fetched so far for a query with result_id after a ifx_query() or 
ifx_do() query. 

Prev Home Next 

ifx_num_fields Up ifx_free_result 



PHP Manual 

Prev Next 



ifx_free_result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_free_result ~ Releases resources for the query 

Description 



int if x_f ree_result(int result_id); 

Releases resources for the query associated with result_id. Returns FALSE on error. 

Prev Home Next 

ifx_num_rows Up ifx_create_char 



PHP Manual 

Prev Next 



ifx_create_char 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_create_char ~ Creates an char object 

Description 

int if x_create_char(string param); 

Creates an char object, param should be the char content. 



Prev Home Next 

ifx_free_result Up ifx_free_char 



PHP Manual 

Prev Next 



ifx free char 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_free_char — Deletes the char object 

Description 



int if x_f ree_char(int bid); 

Deletes the charobject for the given char object-id bid. Returns FALSE on error otherwise TRUE. 

Prev Home Next 

ifx_create_char Up ifx_update_char 



PHP Manual 

Prev Next 



ifx_update_char 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_update_char ~ Updates the content of the char object 

Description 

int if x_update_char(int bid, string content); 



Updates the content of the char object for the given char object bid. content is a string with new 
data. Returns FALSE on error otherwise TRUE. 

Prev Home Next 

ifx_free_char Up ifx_get_char 



PHP Manual 

Prev Next 



ifx_get_char 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_get_char ~ Return the content of the char object 

Description 

int if x_get_char(int bid); 

Returns the content of the char object for the given char object-id bid. 

Prev Home Next 

ifx_update_char Up ifx_create_blob 



PHP Manual 

Prev Next 



ifx create blob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_create_blob ~ Creates an blob object 

Description 



int if x_create_blob(int type, int mode, string param); 

Creates an blob object. 

type: 1 = TEXT, = BYTE 

mode: = blob-object holds the content in memory, 1 = blob-object holds the content in file. 

param: if mode = 0: pointer to the content, if mode = 1: pointer to the filestring. 

Return FALSE on error, otherwise the new blob object-id. 

Prev Home Next 

ifx_get_char U^ ifx_copy_blob 



PHP Manual 

Prev Next 



ifx_copy_blob 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_copy_blob ~ DupHcates the given blob object 

Description 

int if x_copy_blob(int bid); 

DupHcates the given blob object, bid is the ID of the blob object. 

Returns FALSE on error otherwise the new blob object-id. 

Prev Home Next 

ifx_create_blob U^ ifx_free_blob 



PHP Manual 

Prev Next 



ifx free blob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_free_blob ~ Deletes the blob object 

Description 



int if x_f ree_blob(int bid); 

Deletes the blobobject for the given blob object-id bid. Returns FALSE on error otherwise TRUE. 

Prev Home Next 

ifx_copy_blob Up ifx_get_blob 



PHP Manual 

Prev Next 



ifx_get_blob 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_get_blob ~ Return the content of a blob object 

Description 

int ifx_get_blob(intbid); 

Returns the content of the blob object for the given blob object-id bid. 

Prev Home Next 

ifx_free_blob Up ifx_update_blob 



PHP Manual 

Prev Next 



ifx free slob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifx_free_slob ~ Deletes the slob object 

Description 



int ifxus_f ree_slob(intbid); 

Deletes the slob object, bid is the Id of the slob object. Returns FALSE on error otherwise TRUE. 

Prev Home Next 

ifxus_create_slob Up ifxus_close_slob 



PHP Manual 

Prev Next 



ifxus_close_slob 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_close_slob ~ Deletes the slob object 

Description 



int if xus_close_slob(int bid); 

Deletes the slob object on the given slob object-id bid. Return FALSE on error otherwise TRUE. 

Prev Home Next 

ifx_free_slob Up ifxus_open_slob 



PHP Manual 

Prev Next 



ifxus_open_slob 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_open_slob ~ Opens an slob object 

Description 

int if xus_open_slob(long bid, int mode); 

Opens an slob object, bid should be an existing slob id. Modes: 1 = LO_RDONLY, 2 = 
LO_WRONLY, 4 = LO_APPEND, 8 = LO_RDWR, 16 = LO_BUFFER, 32 = LO_NOBUFFER -> 
or-mask. Returns FALSE on error otherwise the new slob object-id. 

Prev Home Next 

ifxus_close_slob Up ifxus_tell_slob 



PHP Manual 

Prev Next 



ifxus tell slob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_tell_slob ~ Returns the current file or seek position 

Description 

int ifxus_tell_slob(long bid); 

Returns the current file or seek position of an open slob object bid should be an existing slob id. 
Return FALSE on error otherwise the seek position. 

Prev Home Next 

ifxus_open_slob Up ifxus_seek_slob 



PHP Manual 

Prev Next 



ifxus seek slob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_seek_slob ~ Sets the current file or seek position 

Description 

int if xus_seek_blob(long bid, int mode, long offset); 

Sets the current file or seek position of an open slob object, i^id should be an existing slob id. 
Modes: = LO_SEEK_SET, 1 = LO_SEEK_CUR, 2 = LO_SEEK_END and offset is an byte 
offset. Return FALSE on error otherwise the seek position. 

Prev Home Next 

ifxus_tell_slob Up ifxus_read_slob 



PHP Manual 

Prev Next 



ifxus read slob 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_read_slob ~ Reads nbytes of the slob object 

Description 

int if xus_read_slob(long bid, long nbytes); 

Reads nbytes of the slob object, i^id is a existing slob id and nbytes is the number of bytes zu 
read. Return FALSE on error otherwise the string. 

Prev Home Next 

ifxus_seek_slob Up ifxus_write_slob 



PHP Manual 

Prev Next 



ifxus_write_slob 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ifxus_write_slob ~ Writes a string into the slob object 

Description 

int if xus_write_slob(long bid, string content); 



Writes a string into the slob object, i^id is a existing slob id and content the content to write. 
Return FALSE on error otherwise bytes written. 

Prev Home Next 

ifxus_read_slob Up InterBase functions 



PHP Manual 

Prev Next 



odbc_close_all 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_close_all ~ Close all ODBC connections 

Description 

void odbc_close_all(void); 

odbc_close_all() will close down all connections to database server(s). 

Note: This function will fail if there are open transactions on a connection. This 
connection will remain open in this case. 

Prev Home Next 

odbc_close U^ odbc_commit 



PHP Manual 

Prev Next 



odbc do 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_do ~ synonym for odbc_exec() 

Description 

string odbc_do(int conn_id, string query); 
odbc_do will execute a query on the given connection 



Prev Home Next 

odbc_cursor Up odbc_exec 



PHP Manual 

Prev Next 



odbc fetch into 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_fetch_into ~ Fetch one result row into array 

Description 

int odbc_f etch_into(int result_id, int [rownumber], array result_array); 

Returns the number of columns in the result; false on error, res ult_array must be passed by 
reference, but it can be of any type since it will be converted to type array. The array will contain 
the column values starting at array index 0. 

Prev Home Next 

odbc_execute Up odbc_fetch_row 



PHP Manual 

Prev Next 



odbc field name 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_field_name ~ Get the columnname 

Description 

string odbc_f ieldname(int result_id, int field_number); 

odbc_field_name() will return the name of the field occupying the given column number in the 
given ODBC result identifier. Field numbering starts at 1. false is returned on error. 

Prev Home Next 

odbc_fetch_row Up odbc_field_type 



PHP Manual 

Prev Next 



odbc exec 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_exec ~ Prepare and execute a SQL statement 

Description 

i n t o db c_e x e c (int connection_id, string query_string) ; 

Returns false on error. Returns an ODBC result identifier if the SQL command was executed 
successfully. 

odbc_exec() will send an SQL statement to the database server specified by connect ion_id. 
This parameter must be a valid identifier returned by odbc_connect() or odbc_pconnect() . 

See also: odbc_prepare() and odbc_execute() for multiple execution of SQL statements. 

Prev Home Next 

odbc_do Up odbc_execute 



PHP Manual 

Prev Next 



odbc result 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



odbc_result ~ get result data 

Description 

string odbc_result(int result_id, mixed field); 

Returns the contents of the field. 

field can either be an integer containing the column number of the field you want; or it can be a 
string containing the name of the field. For example: 

$item_3 = odbc_result ($Query_ID, 3 ) ; 
$item_val = odbc_result ($Query_ID, "val"); 

The first call to odbc_result() returns the value of the third field in the current record of the query 
result. The second function call to odbc_result() returns the value of the field whose field name is 
"val" in the current record of the query result. An error occurs if a column number parameter for a 
field is less than one or exceeds the number of columns (or fields) in the current record. Similarly, 
an error occurs if a field with a name that is not one of the fieldnames of the table(s) that is(are) 
being queried. 

Field indices start from 1 . Regarding the way binary or long column data is returned refer to 
odbc_binmode () and odbc_longreadlen() . 

Prev Home Next 

odbc_num_rows Ug odbc_result_all 



PHP Manual 

Prev Next 



yp_err_string 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



yp_err_string — Returns the error string associated with the previous operation. 

Description 

string yp_err_string(void ); 

yp_err_string() returns the error message associated with the previous operation. Useful to 
indicate what exactly went wrong. 

Example 1. Example for NIS errors 

<?php 

echo "Error: " . yp_err_string ( ) ; 
?> 

See also: yp_ermo 

Prev Home Next 

yp_errno Up ODBC functions 



PHP Manual 

Prev Next 



odbc_autocommit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_autocommit ~ Toggle autocommit behaviour 

Description 

int odbc_autocommit(int connection_id, int [OnOff]); 

Without the On Off parameter, this function returns auto-commit status for connect ion_id. 
True is returned if auto-commit is on, false if it is off or an error occurs. 

If OnOff is true, auto-commit is enabled, if it is false auto-commit is disabled. Returns true on 
success, false on failure. 

By default, auto-commit is on for a connection. Disabling auto-commit is equivalent with starting a 
transaction. 

See also odbc_commit() and odbc_rollback() . 

Prev Home Next 

ODBC functions Up odbc_binmode 



PHP Manual 



Prev 



Next 



odbc binmode 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



|dJ 



odbc_binmode ~ handhng of binary column data 



Description 



int odbc_binmode(int result_id, int mode); 

(ODBC SQL types affected: BINARY, VARBINARY, LONGVARBINARY) 

q ODBC_BINMODE_PASSTHRU: Passthru BINARY data 

q ODBC_BINMODE_RETURN: Return as is 

q ODBC_BINMODE_CONVERT: Convert to char and return 

When binary SQL data is converted to character C data, each byte (8 bits) of source data is 
represented as two ASCII characters. These characters are the ASCII character representation of the 
number in its hexadecimal form. For example, a binary 00000001 is converted to "01 " and a 
binary 11111111 is converted to " FF " . 

Table 1. LONGVARBINARY handling 



binmode 


longreadlen 


result 


ODBC_BINMODE_PASSTHRU 





passthru 


ODBC_BINMODE_RETURN 





passthru 


ODBC_BINMODE_CONVERT 





passthru 


ODBC_BINMODE_PASSTHRU 





passthru 


ODBC_BINMODE_PASSTHRU 


>0 


passthru 


ODBC_BINMODE_RETURN 


>0 


return as is 


ODBC_BINMODE_CONVERT 


>0 


return as char 



If odbc_fetch_into() is used, passthru means that an empty string is returned for these columns. 
If res ul t_id is 0, the settings apply as default for new results. 

Note: Default for longreadlen is 4 9 6 and binmode defaults to 



ODBC_BINMODE_RETURN. Handling of binary long columns is also affected by 
odbc_longreadlen() 

Prev Home Next 

odbc_autocommit U^ odbc_close 



PHP Manual 

Prev Next 



odbc_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_close ~ Close an ODBC connection 

Description 

void odbc_close (int connection_id) ; 



odbc_close() will close down the connection to the database server associated with the given 
connection identifier. 

Note: This function will fail if there are open transactions on this connection. The 
connection will remain open in this case. 

Prev Home Next 

odbc_binmode Up odbc_close_all 



PHP Manual 

Prev Next 



odbc execute 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_execute ~ execute a prepared statement 

Description 

i n t o db c_e x e c u t e (int result_id, array [parameters_array ] ) ; 

Executes a statement prepared with odbc_prepare() . Returns true on successful execution, 
false otherwise. The array arameters_array only needs to be given if you really have 
parameters in your statement. 

Prev Home Next 

odbc_exec Up odbc_fetch_into 



PHP Manual 

Prev Next 



odbc_field_type 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_field_type ~ datatype of a field 

Description 

string odbc_f ield_type(int result_id, int field_number); 

odbc_field_type() will return the SQL type of the field referecend by number in the given ODBC 
result identifier. Field numbering starts at 1 . 

Prev Home Next 

odbc_field_name Up odbc_field_len 



PHP Manual 

Prev Next 



odbc field len 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_field_len ~ get the Length of a field 

Description 

int odbc_f ield_len(int result_id, int field_number); 

odbc_field_len() will return the length of the field referecend by number in the given ODBC result 
identifier. Field numbering starts at 1 . 

Prev Home Next 

odbc_field_type Up odbc_free_result 



PHP Manual 

Prev Next 



odbc_free_result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_free_result ~ free resources associated with a result 

Description 

int odbc_f ree_result(intresult_id); 

Always returns true. 

odbc_free_result() only needs to be called if you are worried about using too much memory while 
your script is running. All result memory will automatically be freed when the script is finished. 
But, if you are sure you are not going to need the result data anymore in a script, you may call 
odbc_free_result(), and the memory associated with result_id will be freed. 

Note: If auto-commit is disabled (see odbc_autocommit() ) and you call 
odbc_free_result() before commiting, all pending transactions are rolled back. 

Prev Home Next 

odbc_field_len Ug odbc_longreadlen 



PHP Manual 

Prev Next 



odbcjongreadlen 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbcjongreadlen ~ handhng of LONG columns 

Description 

int odbc_longreadlen(int result_id, int length); 

(ODBC SQL types affected: LONG, LONGVARBINARY) The number of bytes returned to PHP 
is controled by the parameter length. If it is set to 0, Long column data is passed thru to the client. 

Note: Handling of LONGVARBINARY columns is also affected by odbc_binmode() 

Prev Home Next 

odbc_free_result Ug odbc_num_fields 



PHP Manual 

Prev Next 



od bc_n u m_ro ws 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_num_rows ~ Number of rows in a result 

Description 

int odbc_num_rows(int result_id); 



odbc_num_rows() will return the number of rows in an ODBC result. This function will return -1 
on error. For INSERT, UPDATE and DELETE statements odbc_num_rows() returns the number 
of rows affected. For a SELECT clause this can be the number of rows available. 

Note: Using odbc_num_rows() to determine the number of rows available after a SELECT will 
return -1 with many drivers. 

Prev Home Next 

odbc_prepare Up odbc_result 



PHP Manual 

Prev Next 



odbc result all 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_result_all ~ Print result as HTML table 

Description 

int odbc_result_all(intresult_id, string [format]); 
Returns the number of rows in the result or false on error. 

odbc_result_all() will print all rows from a result identifier produced by odbc_exec() . The result is 

printed in HTML table format. With the optional string argument format, additional overall table 
formatting can be done. 

Prev Home Next 

odbc_result Up odbc_rollback 



PHP Manual 

Prev Next 



odbc rollback 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

odbc_rollback ~ Rollback a transaction 

Description 

int odbc_rollback (int connection_id) ; 



Rolls back all pending statements on connection_id. Returns true on success, false on 
failure. 

Prev Home Next 

odbc_result_all Up odbc_setoption 



PHP Manual 

Prev Next 



odbc_setoption 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



odbc_setoption — Adjust ODBC settings. Returns false if an error occurs, otherwise true. 

Description 

int odbc_setoption(int id, int function, int option, int param); 

This function allows fiddling with the ODBC options for a particular connection or query result. It 
was written to help find work arounds to problems in quirky ODBC drivers. You should probably 
only use this function if you are an ODBC programmer and understand the effects the various 
options will have. You will certainly need a good ODBC reference to explain all the different 
options and values that can be used. Different driver versions support different options. 

Because the effects may vary depending on the ODBC driver, use of this function in scripts to be 
made publicly available is strongly discouraged. Also, some ODBC options are not available to this 
function because they must be set before the connection is established or the query is prepared. 
However, if on a particular job it can make PHP work so your boss doesn't tell you to use a 
commercial product, that's all that really matters. 

Id is a connection id or result id on which to change the settings.For SQLSetConnectOption(), this 
is a connection id. For SQLSetStmtOption(), this is a result id. 

function is the ODBC function to use. The value should be 1 for SQLSetConnectOption() and 2 
for SQLSetStmtOptionO. 

Parmeter option is the option to set. 

Parameter param is the value for the given option. 



Example 1. ODBC Setoption Examples 

// 1. Option 102 of SQLSetConnectOption is SQL_AUTOCOMMIT . 

// Value 1 of SQL_AUTOCOMMIT is SQL_AUTOCOMMIT_ON . 

// This example has the same effect as 

// odbc_autocommit ( $conn, true); 

odbc_setoption ($conn, 1, 102, 1); 

// 2. Option of SQLSetStmtOption is SQL_QUERY_TIMEOUT . 

// This example sets the query to timeout after 30 seconds 

$result = odbc_prepare ($conn, $sql); 
odbc_setoption ($result, 2, 0, 30); 
odbc_execute ($result); 



Prey Home Next 

odbc_rollback Ug Oracle functions 



PHP Manual 

Prev Chapter 6. Types Next 



Floating point numbers 

Floating point numbers ("doubles") can be specified using any of the following syntaxes: 

$a = 1.234; $a = 1.2e3; 



Prev Home Next 

Types Up Strings 



Prev 



PHP Manual 

Chapter 6. Types 



Next 



Strings 



Strings can be specified using one of two sets of delimiters. 

If the string is enclosed in double-quotes ("), variables within the string will be expanded (subject to 
some parsing limitations). As in C and Perl, the backslash ("\") character can be used in specifying 
special characters: 

Table 6-1. Escaped characters 



sequence 


meaning 


\n 


newline 


\r 


carriage 


\t 


horizontal tab 


W 


backslash 


\$ 


dollar sign 


\" 


double-quote 


\[0-7] {1,3} 


the sequence of characters matching the regular expression is a 
character in octal notation 


\x[0-9A-Fa-f ] {1,2} 


the sequence of characters matching the regular expression is a 
character in hexadecimal notation 



You can escape any other character, but a warning will be issued at the highest warning level. 

The second way to delimit a string uses the single-quote ('"") character. When a string is enclosed 
in single quotes, the only escapes that will be understood are "W" and "\"'. This is for convenience, 
so that you can have single-quotes and backslashes in a single-quoted string. Variables will not be 
expanded inside a single-quoted string. 

Another way to delimit strings is by using here doc syntax (">»"). One should provide an 
identifier after >>>, then the string, and then the same identifier to close the quotation. 

Example 6-1. Here doc string quoting example 

$str = >>>EOD 
Example of string 
spanning multiple lines 
using heredoc syntax. 
EOD; 



Note: Here docs was added in PHP 4. 

Strings may be concatenated using the '.' (dot) operator. Note that the '+' (addition) operator will not 
work for this. Please see String operators for more information. 



Characters within strings may be accessed by treating the string as a numerically-indexed array of 
characters, using C-like syntax. See below for examples. 

Example 6-2. Some string examples 

<?php 

/* Assigning a string. */ 

$str = "This is a string"; 

/* Appending to it. */ 

$str = $str . " with some more text"; 

/* Another way to append, includes an escaped newline. */ 
$str .= " and a newline at the end.\n"; 

/* This string will end up being '<p>Number: 9</p>' */ 

$num = 9; 

$str = "<p>Number: $num</p>"; 

/* This one will be '<p>Number: $num</p>' */ 

$num = 9; 

$str = '<p>Number: $num</p>'; 

/* Get the first character of a string */ 
$str = 'This is a test.'; 
$first = $str [0] ; 

/* Get the last character of a string. */ 
$str = 'This is still a test.'; 
$last = $str [strlen ( $str ) -1 ] ; 
?> 



String conversion 



When a string is evaluated as a numeric value, the resulting value and type are determined as 
follows. 

The string will evaluate as a double if it contains any of the characters '.', 'e', or 'E'. Otherwise, it 
will evaluate as an integer. 

The value is given by the initial portion of the string. If the string starts with valid numeric data, 
this will be the value used. Otherwise, the value will be (zero). Valid numeric data is an optional 
sign, followed by one or more digits (optionally containing a decimal point), followed by an 
optional exponent. The exponent is an 'e' or 'E' followed by one or more digits. 

When the first expression is a string, the type of the variable will depend on the second expression. 

$foo = 1 + "10.5"; // $foo is double (11.5) 

$foo = 1 + "-1.3e3"; // $foo is double (-1299) 



$foo = 1 + "bob-1.3e3"; // $foo is integer (1) 

$foo = 1 + "bob3"; // $foo is integer (1) 

$foo = 1 + "10 Small Pigs"; // $foo is integer (11) 

$foo = 1 + "10 Little Piggies"; // $foo is integer (11) 

$foo = "10.0 pigs " + 1; // $foo is integer (11) 

$foo = "10.0 pigs " + 1.0; // $foo is double (11) 

For more information on this conversion, see tlie Unix manual page for strtod(3). 

If you would like to test any of the examples in this section, you can cut and paste the examples and 
insert the following line to see for yourself what's going on: 

echo " \$f oo==$f oo; type is " . gettype ( $foo ) . "<br>\n"; 



Prev Home Next 

Floating point numbers U^ Arrays 



PHP Manual 

Prev Chapter 6. Types Next 

Arrays 

Arrays actually act like both hash tables (associative arrays) and indexed arrays (vectors). 

Single Dimension Arrays 

PHP supports both scalar and associative arrays. In fact, there is no difference between the two. You can create an 
array using the listQ or arrayQ functions, or you can explicitly set each array element value. 

$a[0] = "abc"; 
$a[l] = "def"; 
$b["foo"] = 13; 

You can also create an array by simply adding values to the array. When you assign a value to an array variable 
using empty brackets, the value will be added onto the end of the array. 

$a[] = "hello"; // $a[2] == "hello" 
$a[] = "world"; // $a[3] == "world" 

Arrays may be sorted using the asortQ , arsortQ , ksortQ , rsortQ , sortQ , uasortQ , usortQ , and uksortQ functions 
depending on the type of sort you want. 

You can count the number of items in an array using the countQ function. 

You can traverse an array using nextQ and prevQ functions. Another common way to traverse an array is to use the 
each() function. 



Multi-Dimensional Arrays 



Multi-dimensional arrays are actually pretty simple. For each dimension of the array, you add another [key] value to 
the end: 

$a[l] = $f; # one dimensional examples 

$a["foo"] = $f; 

$a[l] [0] = $f; # two dimensional 

$a["foo"] [2] = $f; # (you can mix numeric and associative indices) 

$a[3] ["bar"] = $f; # (you can mix numeric and associative indices) 

$a["foo"] [4] ["bar"] [0] = $f; # four dimensional! 

In PHP3 it is not possible to reference multidimensional arrays directly within strings. For instance, the following 
will not have the desired result: 

$a[3] [ 'bar' ] = 'Bob' ; 

echo "This won't work: $a[3] [bar]"; 



In PHP3, the above will output This won't work: Array [bar] . The string concatenation operator, 
however, can be used to overcome this: 

$a[3] [ 'bar' ] = 'Bob' ; 

echo "This will work: " . $a[3][bar]; 

In PHP4, however, the whole problem may be circumvented by enclosing the array reference (inside the string) in 
curly braces: 

$a[3] [ 'bar' ] = 'Bob' ; 

echo "This will work: { $a [3] [bar ] } " ; 

You can "fill up" multi-dimensional arrays in many ways, but the trickiest one to understand is how to use the 
arrayO command for associative arrays. These two snippets of code fill up the one-dimensional array in the same 
way: 

# Example 1 : 

$a[ "color"] = "red"; 

$a ["taste"] = "sweet"; 

$a ["shape"] = "round"; 

$a["name"] = "apple"; 

$a[3] =4; 

# Example 2 : 
$a = array ( 

"color" => "red", 
"taste" => "sweet", 
"shape" => "round", 
"name" => "apple", 
3 => 4 

); 

The arrayO function can be nested for multi-dimensional arrays: 

<? 

$a = array ( 

"apple" => array ( 

"color" => "red", 
"taste" => "sweet", 
"shape" => "round" 

), 

"orange" => array ( 

"color" => "orange", 
"taste" => "tart", 
"shape" => "round" 

), 

"banana" => array ( 

"color" => "yellow", 
"taste" => "paste-y", 
"shape" => "banana-shaped" 



echo $a[ "apple"] ["taste"]; # will output "sweet" 

?> 



Prev Home Next 

Strings Ug Objects 



PHP Manual 

Prev Chapter 6. Types Next 



Objects 

Object Initialization 



To initialize an object, you use the new statement to instantiate the object to a variable. 

class foo { 

function do_foo () { 

echo "Doing f oo . " ; 

} 
} 

$bar = new foo; 
$bar->do_f oo ( ) ; 



Prev Home Next 

Arrays Up Type juggling 



PHP Manual 

Prev Chapter 6. Types Next 



Type juggling 



PHP does not require (or support) explicit type definition in variable declaration; a variable's type is 
determined by the context in which that variable is used. That is to say, if you assign a string value 
to variable var, var becomes a string. If you then assign an integer value to var, it becomes an 
integer. 

An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands 
is a double, then all operands are evaluated as doubles, and the result will be a double. Otherwise, 
the operands will be interpreted as integers, and the result will also be an integer. Note that this 
does NOT change the types of the operands themselves; the only change is in how the operands are 
evaluated. 

$foo = "0"; // $foo is string (ASCII 48) 

$foo++; // $foo is the string "1" (ASCII 49) 

$foo += 1; // $foo is now an integer (2) 

$foo = $foo + 1.3; // $foo is now a double (3.3) 

$foo = 5 + "10 Little Piggies"; // $foo is integer (15) 

$foo = 5 + "10 Small Pigs"; // $foo is integer (15) 

If the last two examples above seem odd, see String conversion . 

If you wish to force a variable to be evaluated as a certain type, see the section on Type casting . If 
you wish to change the type of a variable, see settypeQ . 

If you would like to test any of the examples in this section, you can cut and paste the examples and 
insert the following line to see for yourself what's going on: 

echo " \$f oo==$f oo; type is " . gettype ( $foo ) . "<br>\n"; 

Note: The behaviour of an automatic conversion to array is currently undefined. 

$a = 1; // $a is an integer 

$a[0] = "f"; // $a becomes an array, with $a[0] holding "f" 

While the above example may seem like it should clearly result in $a becoming an 
array, the first element of which is 'f, consider this: 

$a = "1"; // $a is a string 

$a[0] = "f"; // What about string offsets? What happens? 

Since PHP supports indexing into strings via offsets using the same syntax as array 
indexing, the example above leads to a problem: should $a become an array with its 



first element being "f" , or should "f" become the first character of the string $a? 

For this reason, as of PHP 3.0.12 and PHP 4.0b3-RC4, the result of this automatic 
conversion is considered to be undefined. Fixes are, however, being discussed. 



Type casting 



Type casting in PHP works much as it does in C: the name of the desired type is written in 
parentheses before the variable which is to be cast. 

$foo = 10; // $foo is an integer 

$bar = (double) $foo; // $bar is a double 

The casts allowed are: 

q (int), (integer) - cast to integer 

q (real), (double), (float) - cast to double 

q (string) - cast to string 

q (array) - cast to array 

q (object) - cast to object 

Note that tabs and spaces are allowed inside the parentheses, so the following are functionally 
equivalent: 

$foo = (int) $bar; 
$foo = ( int ) $bar; 

It may not be obvious exactly what will happen when casting between certain types. For instance, 
the following should be noted. 

When casting from a scalar or a string variable to an array, the variable will become the first 
element of the array: 

$var = ' ciao ' ; 

$arr = (array) $var; 

echo $arr[0]; // outputs 'ciao' 

When casting from a scalar or a string variable to an object, the variable will become an attribute of 
the object; the attribute name will be 'scalar': 

$var = ' ciao ' ; 

$obj = (object) $var; 

echo $ob j->scalar; // outputs 'ciao' 



Prev Home Next 

Objects Up Variables 



PHP Manual 

Prev Next 



settype 

settype ~ Set the type of a variable. 

Description 

int set type (string var, string type); 
Set the type of variable var to type. 
Possibles values of type are: 

q "integer" 

q "double" 

q "string" 

q "array" 

q "object" 
Returns true if successful; otherwise returns false. 
See also gettypeQ. 



Prev Home Next 

isset Up strval 



PHP Manual 

Prev Chapter 7. Variables Next 



Predefined variables 



PHP provides a large number of predefined variables to any script which it runs. Many of these 
variables, however, cannot be fully documented as they are dependent upon which server is 
running, the version and setup of the server, and other factors. Some of these variables will not be 
available when PHP is run on the command-line. 

Despite these factors, here is a list of predefined variables available under a stock installation of 
PHP 3 running as a module under a stock installation of Apache 1.3.6. 

For a list of all predefined variables (and lots of other useful information), please see (and use) 
phpinfoQ . 

Note: This list is neither exhaustive nor intended to be. It is simply a guideline as to 
what sorts of predefined variables you can expect to have access to in your script. 



Apache variables 



These variables are created by the Apache webserver. If you are running another webserver, there is 
no guarantee that it will provide the same variables; it may omit some, or provide others not listed 
here. That said, a large number of these variables are accounted for in the CGI 1.1 specification , so 
you should be able to expect those. 

Note that few, if any, of these will be available (or indeed have any meaning) if running PHP on the 
command line. 

GATEWAYJNTERFACE 

What revision of the CGI specification the server is using; i.e. 'CGI/1. 1'. 
SERVER_NAME 

The name of the server host under which the current script is executing. If the script is 
running on a virtual host, this will be the value defined for that virtual host. 

SERVER_SOFTWARE 

Server identification string, given in the headers when responding to requests. 
SERVER_PROTOCOL 

Name and revision of the information protocol via which the page was requested; i.e. 
'HTTP/1.0'; 

REQUEST_METHOD 

Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'. 
QUERY_STRING 



The query string, if any, via which the page was accessed. 
DOCUMENT_ROOT 

The document root directory under which the current script is executing, as defined in the 
server's configuration file. 

HTTP_ACCEPT 

Contents of the Accept : header from the current request, if there is one. 
HTTP_ACCEPT_CHARSET 

Contents of the Accept-Char set : header from the current request, if there is one. 
Example: 'iso-8859-l,*,utf-8'. 

HTTP_ENCODING 

Contents of the Accept-Encoding : header from the current request, if there is one. 
Example: 'gzip'. 

HTTP_ACCEPT_LANGUAGE 

Contents of the Accept-Language : header from the current request, if there is one. 
Example: 'en'. 

HTTP_CONNECTION 

Contents of the Connection : header from the current request, if there is one. Example: 
'Keep-Alive'. 

HTTP_HOST 

Contents of the Host : header from the current request, if there is one. 
HTTP_REFERER 

The address of the page (if any) which referred the browser to the current page. This is set by 
the user's browser; not all browsers will set this. 

HTTP_USER_ AGENT 

Contents of the User_Agent : header from the current request, if there is one. This is a 
string denoting the browser software being used to view the current page; i.e. 
Mozilla/4.5 [en] (Xll; U; Linux 2.2.9 i 5 8 6 ). Among other things, you 
can use this value with get_browser() to tailor your page's functionality to the capabilities of 
the user's browser. 
REMOTE_ADDR 

The IP address from which the user is viewing the current page. 
REMOTE_PORT 

The port being used on the user's machine to communicate with the web server. 
SCRIPT_FILENAME 

The absolute pathname of the currently executing script. 
SERVER ADMIN 



The value given to the SERVER_ADMIN (for Apache) directive in the web server 
configuration file. If the script is running on a virtual host, this will be the value defined for 
that virtual host. 

SERVER_PORT 

The port on the server machine being used by the web server for communication. For default 
setups, this will be '80'; using SSL, for instance, will change this to whatever your defined 
secure HTTP port is. 

SERVER_SIGNATURE 

String containing the server version and virtual host name which are added to 
server-generated pages, if enabled. 

PATH_TRANSLATED 

Filesystem- (not document root-) based path to the current script, after the server has done 
any virtual-to-real mapping. 

SCRIPT_NAME 

Contains the current script's path. This is useful for pages which need to point to themselves. 
REQUEST_URI 

The URI which was given in order to access this page; for instance, '/index.html'. 

Environment variables 

These variables are imported into PHP's global namespace from the environment under which the 
PHP parser is running. Many are provided by the shell under which PHP is running and different 
systems are likely running different kinds of shells, a definitive list is impossible. Please see your 
shell's documentation for a list of defined environment variables. 

Other environment variables include the CGI variables, placed there regardless of whether PHP is 
running as a server module or CGI processor. 

PHP variables 

These variables are created by PHP itself. 

argv 

Array of arguments passed to the script. When the script is run on the command line, this 
gives C-style access to the command line parameters. When called via the GET method, this 
will contain the query string. 

argc 

Contains the number of command line parameters passed to the script (if run on the 
command line). 

PHP SELF 



The filename of the currently executing script, relative to the document root. If PHP is 
running as a command-line processor, this variable is not available. 

HTTP_COOKIE_VARS 

An associative array of variables passed to the current script via HTTP cookies. Only 
available if variable tracking has been turned on via either the track_vars configuration 
directive or the <?php_track_vars?> directive. 
HTTP_GET_VARS 

An associative array of variables passed to the current script via the HTTP GET method. 
Only available if variable tracking has been turned on via either the track_vars configuration 
directive or the <?php_track_vars?> directive. 
HTTP_POST_VARS 

An associative array of variables passed to the current script via the HTTP POST method. 
Only available if variable tracking has been turned on via either the track_vars configuration 
directive or the <?php_track_vars?> directive. 

Prev Home Next 

Variables Ug Variable scope 



PHP Manual 

Prev Chapter 7. Variables Next 



Variable scope 



The scope of a variable is the context within which it is defined. For the most part all PHP variables 
only have a single scope. This single scope spans included and required files as well. For example: 

$a = 1; 

include "b.inc"; 

Here the $a variable will be available within the included b.inc script. However, within 
user-defined functions a local function scope is introduced. Any variable used inside a function is 
by default limited to the local function scope. For example: 

$a = 1; /* global scope */ 

Function Test () { 

echo $a; /* reference to local scope variable */ 
} 

Test 0; 

This script will not produce any output because the echo statement refers to a local version of the $a 
variable, and it has not been assigned a value within this scope. You may notice that this is a little 
bit different from the C language in that global variables in C are automatically available to 
functions unless specifically overridden by a local definition. This can cause some problems in that 
people may inadvertently change a global variable. In PHP global variables must be declared global 
inside a function if they are going to be used in that function. An example: 

$a = 1; 
$b = 2; 

Function Sum () { 
global $a, $b; 

$b = $a + $b; 
} 

Sum ( ) ; 
echo $b; 

The above script will output "3". By declaring $a and $b global within the function, all references 
to either variable will refer to the global version. There is no limit to the number of global variables 
that can be manipulated by a function. 



A second way to access variables from the global scope is to use the special PHP-defined 
$GLOBALS array. The previous example can be rewritten as: 

$a = 1; 
$b = 2; 

Function Sum () { 

$GLOBALS ["b"] = $GLOBALS [ "a" ] + $GLOBALS [ "b" ] ; 
} 

Sum 0; 
echo $b; 

The $GLOB ALS array is an associative array with the name of the global variable being the key 
and the contents of that variable being the value of the array element. 

Another important feature of variable scoping is the static variable. A static variable exists only in a 
local function scope, but it does not lose its value when program execution leaves this scope. 
Consider the following example: 

Function Test () { 

$a = 0; 

echo $a; 

$a++; 
} 

This function is quite useless since every time it is called it sets $a to and prints "0". The $a++ 
which increments the variable serves no purpose since as soon as the function exits the $a variable 
disappears. To make a useful counting function which will not lose track of the current count, the 
$a variable is declared static: 

Function Test () { 

static $a = 0; 

echo $a; 

$a++; 
} 

Now, every time the Test() function is called it will print the value of $a and increment it. 

Static variables also provide one way to deal with recursive functions. A recursive function is one 
which calls itself. Care must be taken when writing a recursive function because it is possible to 
make it recurse indefinitely. You must make sure you have an adequate way of terminating the 
recursion. The following simple function recursively counts to 10, using the static variable $count 
to know when to stop: 

Function Test () { 

static $count = 0; 

$count++; 



echo $count; 
if ($count < 10) { 
Test 0; 

} 

$count — ; 



Prev Home Next 

Predefined variables Ug Variable variables 



PHP Manual 

Prev Chapter 7. Variables Next 



Variable variables 



Sometimes it is convenient to be able to have variable variable names. That is, a variable name 
which can be set and used dynamically. A normal variable is set with a statement such as: 

$a = "hello"; 

A variable variable takes the value of a variable and treats that as the name of a variable. In the 
above example, hello, can be used as the name of a variable by using two dollar signs, i.e. 

$$a = "world"; 

At this point two variables have been defined and stored in the PHP symbol tree: $a with contents 
"hello" and $hello with contents "world". Therefore, this statement: 

echo "$a ${$a}"; 

produces the exact same output as: 

echo "$a $hello"; 

i.e. they both produce: hello world. 

In order to use variable variables with arrays, you have to resolve an ambiguity problem. That is, if 
you write $$a[l] then the parser needs to know if you meant to use $a[l] as a variable, or if you 
wanted $$a as the variable and then the [1] index from that variable. The syntax for resolving this 
ambiguity is: ${$a[l]} for the first case and ${$a}[l] for the second. 

Prev Home Next 

Variable scope U^ Variables from outside PHP 



PHP Manual 

Prev Chapter 7. Variables Next 



Variables from outside PIHP 

HTML Forms (GET and POST) 

When a form is submitted to a PHP script, any variables from that form will be automatically made 
available to the script by PHP. For instance, consider the following form: 

Example 7-1. Simple form variable 

<form action="f oo .php3" method="post "> 

Name: <input type="text" name="name"><br> 

<input type=" submit "> 
</f orm> 



When submitted, PHP will create the variable $name, which will will contain whatever what 
entered into the Name: field on the form. 

PHP also understands arrays in the context of form variables, but only in one dimension. You may, 
for example, group related variables together, or use this feature to retrieve values from a multiple 
select input: 

Example 7-2. More complex form variables 

<form action="array .php" method="post "> 

Name: <input type="text" name="personal [name] "><br> 
Email: <input type="text" name="personal [email] "><br> 
Beer: <br> 
<select multiple name="beer [ ] "> 

< opt ion value="warthog">Warthog 

< opt ion value="guinness">Guinness 

<option value="stuttgarter ">Stuttgarter Schwabenbrau 

</select> 
<input type=" submit "> 
</f orm> 

If PHP's track_vars feature is turned on, either by the track_vars configuration setting or the 
<?php_track_vars?> directive, then variables submitted via the POST or GET methods will 
also be found in the global associative arrays $HTTP_POST_VARS and $HTTP_GET_VARS as 
appropriate. 



IMAGE SUBMIT variable names 

When submitting a form, it is possible to use an image instead of the standard submit button with a 
tag Hke: 

<input type=image src="image . gif " name="sub"> 

When the user cHcks somewhere on the image, the accompanying form will be transmitted to the 
server with two additional variables, sub_x and sub_y. These contain the coordinates of the user 
click within the image. The experienced may note that the actual variable names sent by the 
browser contains a period rather than an underscore, but PHP converts the period to an underscore 
automatically. 

HTTP Cookies 

PHP transparently supports HTTP cookies as defined by Netscape's Spec . Cookies are a mechanism 
for storing data in the remote browser and thus tracking or identifying return users. You can set 
cookies using the SetCookieQ function. Cookies are part of the HTTP header, so the SetCookie 
function must be called before any output is sent to the browser. This is the same restriction as for 
the HeaderQ function. Any cookies sent to you from the client will automatically be turned into a 
PHP variable just like GET and POST method data. 

If you wish to assign multiple values to a single cookie, just add [] to the cookie name. For 
example: 

SetCookie ( "MyCookie [ ] " , "Testing", time () +3600 ) ; 

Note that a cookie will replace a previous cookie by the same name in your browser unless the path 
or domain is different. So, for a shopping cart application you may want to keep a counter and pass 
this along, i.e. 

Example 7-3. SetCookie Example 

$Count++; 

SetCookie ("Count", $Count, time () +3 60 ) ; 

SetCookie ( "Cart [$Count ] " , $item, time () +3600 ) ; 



Environment variables 

PHP automatically makes environment variables available as normal PHP variables. 

echo $HOME; /* Shows the HOME environment variable, if set. */ 

Since information coming in via GET, POST and Cookie mechanisms also automatically create 
PHP variables, it is sometimes best to explicitly read a variable from the environment in order to 
make sure that you are getting the right version. The getenvQ function can be used for this. You 
can also set an environment variable with the putenvQ function. 



Dots in incoming variable names 

Typically, PHP does not alter the names of variables when they are passed into a script. However, it 
should be noted that the dot (period, full stop) is not a valid character in a PHP variable name. For 
the reason, look at it: 

$varname . ext ; /* invalid variable name */ 

Now, what the parser sees is a variable named $varname, followed by the string concatenation 
operator, followed by the barestring (i.e. unquoted string which doesn't match any known key or 
reserved words) 'ext'. Obviously, this doesn't have the intended result. 

For this reason, it is important to note that PHP will automatically replace any dots in incoming 
variable names with underscores. 



Determining variable types 



Because PHP determines the types of variables and converts them (generally) as needed, it is not 
always obvious what type a given variable is at any one time. PHP includes several functions which 
find out what type a variable is. They are gettypeQ , is_long() , is_double() , is_string() , is_array() , 
and is_object() . 

Prev Home Next 

Variable variables U^ Constants 



PHP Manual 

Prev Next 



ereg 



■This function is not supported in tl^^^f 
PHP Lite edition. ^^H 

^^ossible workaround not yet published. J 



ereg — regular expression match 

Description 

int ereg(string pattern, string string, array [regs]); 

Searchs st ring ior matches to the regular expression given in pa 1 1 em. 

If matches are found for parenthesized substrings of pattern and the function is called with the third 
argument regs, the matches will be stored in the elements of regs. $regs[l] will contain the 
substring which starts at the first left parenthesis; $regs[2] will contain the substring starting at the 
second, and so on. $regs[0] will contain a copy of string. 

Searching is case sensitive. 

Returns true if a match for pattern was found in string, or false if no matches were found or an error 
occurred. 

The following code snippet takes a date in ISO format (YYYY-MM-DD) and prints it in 
DD.MM.YYYY format: 

Example 1. eregO example 

if ( ereg( " ( [0-9] { 4 } ) - ( [0-9] { 1, 2 } ) - ( [0-9] { 1, 2 } ) " , $date, $regs ) ) { 

echo "$regs[3] .$regs[2] .$regs[l]"; 
} else { 

echo "Invalid date format: $date"; 
} 

See also eregiQ , ereg_replace() , and eregi_replace() . 

Prev Home Next 

Regular expression functions Up ereg_replace 



PHP Manual 

Prev Chapter 10. Operators Next 



Assignment Operators 



The basic assignment operator is "=". Your first inclination might be to think of this as "equal to". Don't. It 
really means that the the left operand gets set to the value of the expression on the rights (that is, "gets set to"). 

The value of an assignment expression is the value assigned. That is, the value of "$a = 3" is 3. This allows you 
to do some tricky things: 

$a = ($b = 4) + 5; // $a is equal to 9 now, and $b has been set to 4. 

In addition to the basic assignment operator, there are "combined operators" for all of the binary arithmetic and 
string operators that allow you to use a value in an expression and then set its value to the result of that 
expression. For example: 

$a = 3; 

$a += 5; // sets $a to 8, as if we had said: $a = $a + 5; 

$b = "Hello "; 

$b .= "There!"; // sets $b to "Hello There!", just like $b = $b . "There!"; 

Note that the assignment copies the original variable to the new one (assignment by value), so changes to one 
will not affect the other. This may also have relevance if you need to copy something like a large array inside a 
tight loop. PHP4 supports assignment by reference, using the $var = & $othervar ; syntax, but this is not 
possible in PHP3. 'Assignment by reference' means that both variables end up pointing at the same data, and 
nothing is copied anywhere. 

Prev Home Next 

Operators IJp Bitwise Operators 



Prev 



PHP Manual 

Chapter 10. Operators 



Next 



Bitwise Operators 

Bitwise operators allow you to turn specific bits within an integer on or off. 
Table 10-2. Bitwise Operators 



example 


name 


result 


$a&$b 


And 


Bits that are set in both $a and $b are set. 


$al$b 


Or 


Bits that are set in either $a or $b are set. 


$a^$b 


Xor 


Bits that are set in $a or $b but not both are set. 


~$a 


Not 


Bits that are set in $a are not set, and vice versa. 


$a « $b 


Shift left 


Shift the bits of $a $b steps to the left (each step means "multiply by two") 


$a » $b 


Shift right 


Shift the bits of $a $b steps to the right (each step means "divide by two") 



Prev 

Assignment Operators 



Home 
Up 



Next 
Comparison Operators 



Prev 



PHP Manual 

Chapter 10. Operators 



Next 



Logical Operators 



Table 10-5. Logical Operators 



example 


name 


result 


$a and $b 


And 


True if both $a and $b are true. 


$a or $b 


Or 


True if either $a or $b is true. 


$a xor $b 


Or 


True if either $a or $b is true, but not both. 


!$a 


Not 


True if $a is not true. 


$a && $b 


And 


True if both $a and $b are true. 


$a II $b 


Or 


True if either $a or $b is true. 



The reason for the two different variations of "and" and "or" operators is that they operate at 
different precedences. (See Operator Precedence .) 



Prev 

Incrementing/Decrementing 

Operators 



Home 
Up 



Next 
Operator Precedence 



Prev 



PHP Manual 

Chapter 10. Operators 



Next 



Operator Precedence 



The precedence of an operator specifies how "tightly" it binds two expressions together. For 
example, in the expression 1 + 5 * 3, the answer is 16 and not 18 because the multiplication 
("*") operator has a higher precedence than the addition ("+") operator. 

The following table lists the precedence of operators with the lowest-precedence operators listed 
first. 

Table 10-6. Operator Precedence 



Associativity 


Operators 


left 


5 


left 


or 


left 


xor 


left 


and 


right 


print 


left 


= += -= *= /= .= %= &= 1= A^ ^^ «^ »^ 


left 


7 : 


left 


II 


left 


&& 


left 


1 


left 


A 


left 


& 


non-associative 


== != === 


non-associative 


<<=>>= 


left 


«» 


left 


+ - . 


left 


*/% 


right 


!-++-- (int) (double) (string) (array) (object) @ 


right 


L 


non-associative 


new 



Prev 

Logical Operators 



Home 
Up 



Next 
String Operators 



PHP Manual 

Prev Next 



XVI. filePro functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions allow read-only access to data stored in filePro databases. 

filePro is a registered trademark of Fiserv, Inc. You can find more information about filePro at 
http://www.fileproplus.com/ . 

Table of Contents 

// filepro read and verify the map file 

// filepro_fieldname gets the name of a field 

// filepro_fieldtype gets the type of a field 

// filepro_fieldwidth gets the width of a field 

// filepro_retrieve retrieves data from a filePro database 

// filepro_fieldcount find out how many fields are in a filePro database 

// filepro_rowcount find out how many rows are in a filePro database 

Prev Home Next 

mcrypt_ofb Ug filepro 



PHP Manual 

Prev Next 



Chapter 21 . Persistent database 
connections 

Persistent connections are SQL links that do not close when the execution of your script ends. 
When a persistent connection is requested, PHP checks if there's already an identical persistent 
connection (that remained open from earlier) - and if it exists, it uses it. If it does not exist, it 
creates the link. An 'identical' connection is a connection that was opened to the same host, with the 
same username and the same password (where applicable). 

People who aren't thoroughly familiar with the way web servers work and distribute the load may 
mistake persistent connects for what they're not. In particular, they do not give you an ability to 
open 'user sessions' on the same SQL link, they do not give you an ability to build up a transaction 
efficently, and they don't do a whole lot of other things. In fact, to be extremely clear about the 
subject, persistent connections don't give you any functionality that wasn't possible with their 
non-persistent brothers. 

Why? 

This has to do with the way web servers work. There are three ways in which your web server can 
utilize PHP to generate web pages. 

The first method is to use PHP as a CGI "wrapper". When run this way, an instance of the PHP 
interpreter is created and destroyed for every page request (for a PHP page) to your web server. 
Because it is destroyed after every request, any resources that it acquires (such as a link to an SQL 
database server) are closed when it is destroyed. In this case, you do not gain anything from trying 
to use persistent connections ~ they simply don't persist. 

The second, and most popular, method is to run PHP as a module in a multiprocess web server, 
which currently only includes Apache. A multiprocess server typically has one process (the parent) 
which coordinates a set of processes (its children) who actually do the work of serving up web 
pages. When each request comes in from a a client, it is handed off to one of the children that is not 
already serving another client. This means that when the same client makes a second request to the 
server, it may be serviced by a different child process than the first time. What a persistent 
connection does for you in this case it make it so each child process only needs to connect to your 
SQL server the first time that it serves a page that makes us of such a connection. When another 
page then requires a connection to the SQL server, it can reuse the connection that child established 
earlier. 

The last method is to use PHP as a plug-in for a multithreaded web server. Currently this is only 
theoretical ~ PHP does not yet work as a plug-in for any multithreaded web servers. Work is 
progressing on support for ISAPI, WSAPI, and NSAPI (on Windows), which will all allow PHP to 
be used as a plug-in on multithreaded servers like Netscape FastTrack, Microsoft's Internet 
Information Server (IIS), and O'Reilly's WebSite Pro. When this happens, the behavior will be 



essentially the same as for the multiprocess model described before. 

If persistent connections don't have any added functionality, what are they good for? 

The answer here is extremely simple ~ efficiency. Persistent connections are good if the overhead 
to create a link to your SQL server is high. Whether or not this overhead is really high depends on 
many factors. Like, what kind of database it is, whether or not it sits on the same computer on 
which your web server sits, how loaded the machine the SQL server sits on is and so forth. The 
bottom line is that if that connection overhead is high, persistent connections help you considerably. 
They cause the child process to simply connect only once for its entire lifespan, instead of every 
time it processes a page that requires connecting to the SQL server. This means that for every child 
that opened a persistent connection will have its own open persistent connection to the server. For 
example, if you had 20 different child processes that ran a script that made a persistent connection 
to your SQL server, you'd have 20 different connections to the SQL server, one from each child. 

An important summary. Persistent connections were designed to have one-to-one mapping to 
regular connections. That means that you should always be able to replace persistent connections 
with non-persistent connections, and it won't change the way your script behaves. It may (and 
probably will) change the efficiency of the script, but not its behavior! 

Prev Home Next 

Connection handling Up Function Reference 



PHP Manual 

Prev Next 



I. Adabas D functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



The Adabas D functions are deprecated, you probably want to use the Unified ODBC functions 

instead. 

Table of Contents 

// ada_afetch fetch a result row into an array 

// ada_autocommit toggle autocommit behaviour 

// ada_close close a connection to an Adabas D server 

// ada_commit commit a transaction 

// ada_connect connect to an Adabas D datasource 

// ada_exec prepare and execute a SQL statement 

// ada_fetchrow fetch a row from a result 

// ada_fieldname get the columnname 

// ada_fieldnum get column number 

// ada_fieldtype get the datatype of a field 

// ada_freeresult >free resources associated with a result 

// ada_numfields get the number of columns in a result 

// ada_numrows number of rows in a result 

// ada_result get data from results 

// ada_resultall print result as HTML table 

// ada_rollback rollback a transaction 

Prev Home Next 

Function Reference Up ada_afetch 



PHP Manual 

Prev Next 



IV. Array functions 



Table of Contents 

array Create an array 

// array _count_values Counts all the values of an array 

// array _flip Flip all the values of an array 

// array _keys Return all the keys of an array 

// array _merge Merge two or more arrays 

// array _pad Pad array to the specified length with a value 

// array _pop Pop the element off the end of array 

// array _push Push one or more elements onto the end of array 

// array _reverse Return an array with elements in reverse order 

// array_shift Pop an element off the beginning of array 

// array_slice Extract a slice of the array 

// array_splice Remove a portion of the array and replace it with something else 

// array _unshift Push one or more elements onto the beginning of array 

// array _values Return all the values of an array 

// array _walk Apply a user function to every member of an array. 

// arsort Sort an array in reverse order and maintain index association 

// asort Sort an array and maintain index association 

// compact Create array containing variables and their values 

count count elements in a variable 

// current Return the current element in an array 

// each Return the next key and value pair from an array 

//end Set the internal pointer of an array to its last element 

extract Import variables into the symbol table from an array 

// in_array Return true if a value exists in an array 

//key Fetch a key from an associative array 

// krsort Sort an array by key in reverse order 

// ksort Sort an array by key 

list Assign variables as if they were an array 



// next Advance the internal array pointer of an array 

//pos Get the current element from an array 

// prev Rewind the internal array pointer 

// range Create an array containing a range of integers 

// reset Set the internal pointer of an array to its first element 

// rsort Sort an array in reverse order 

// shuffle Shuffle an array 

// sizeof Get the number of elements in an array 

// sort Sort an array 

// uasort Sort an array with a user-defined comparison function and maintain index association 

// uksort Sort an array by keys using a user-defined comparison function 

// usort Sort an array by values using a user-defined comparison function 

Prev Home Next 

bcsub Up array 



PHP Manual 

Prev Next 



V. Aspell functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



The aspellO functions allows you to check the spelling on a word and offer suggestions. 

You need the aspell library, available from: http://metalab.unc.edu/kevina/aspell/ 

Table of Contents 

// aspell_new load a new dictionary 

// aspell_check check a word 

// aspell_check-raw check a word without changing its case or trying to trim it 

// aspell_suggest suggest spellings of a word 

Prev Home Next 

usort Ug aspell_new 



PHP Manual 

Prev Next 



VI. Calendar functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



The calendar functions are only available if you have compiled the calendar extension in 
dl/calendar. Read dl/README for instructions on using it. 

The calendar extension presents a series of functions to simplify converting between different 

calendar formats. The intermediary or standard it is based on is the Julian Day Count. The Julian 

Day Count is a count of days starting way earlier than any date most people would need to track 

(somewhere around 4000bc). To convert between calendar systems, you must first convert to Julian 

Day Count, then to the calendar system of your choice. Julian Day Count is very different from the 

Julian Calendar! For more information on calendar systems visit 

http://genealogy.org/~scottlee/cal-overview.html . Excerpts from this page are included in these 

instructions, and are in quotes. 

Table of Contents 

// JDToGregorian Converts Julian Day Count to Gregorian date 

// GregorianToJD Converts a Gregorian date to Julian Day Count 

// JDToJulian Converts a Julian Calendar date to Julian Day Count 

// JulianToJD Converts a Julian Calendar date to Julian Day Count 

// JDToJewish Converts a Julian Day Count to the Jewish Calendar 

// JewishToJD Converts a date in the Jewish Calendar to Julian Day Count 

// JDToFrench Converts a Julian Day Count to the French Republican Calendar 

// FrenchToJD Converts a date from the French Republican Calendar to a Julian Day Count 

// JDMonthName Returns a month name 

// JDDayOfWeek Returns the day of the week 

// easter_date get UNIX timestamp for midnight on Easter of a given year 

// easter_days get number of days after March 21 on which Easter falls for a given year 

Prev Home Next 

aspell_suggest Up JDToGregorian 



PHP Manual 

Prev Next 



VII. ClibPDF functions 



tese ftmclioiis are not suppd? 
IP Lite edition. 

3ok at the functions manual-page toj 
be if possible workaround exists. 



ClibPDF lets you create PDF documents with PHP. It is available at FastIO but it isn't free software. You should definitely 
read the licence before you start playing with ClibPDF. If you cannot fullfil the licence agreement consider using pdflib by 
Thomas Merz, which is also very powerful. ClibPDF functionality and API is similar to Thomas Merz's pdflib but, 
according to FastIO, ClibPDF is faster and creates smaller documents. This may have changed with the new version 2.0 of 
pdflib. A simple benchmark (the pdfclock.c example from pdflib 2.0 turned into a php script) actually shows no difference 
in speed at all. The file size is also similar if compression is turned off. So, try them both and see which one does the job 
for you. 

This documentation should be read alongside the ClibPDF manual since it explains the library in much greater detail. 

Many functions in the native ClibPDF and the PHP module, as well as in pdflib, have the same name. All functions except 
for cpdf_open() take the handle for the document as their first parameter. Currently this handle is not used internally since 
ClibPDF does not support the creation of several PDF documents at the same time. Actually, you should not even try it, 
the results are unpredictable. I can't oversee what the consequences in a multi threaded environment are. According to the 
author of ClibPDF this will change in one of the next releases (current version when this was written is 1.10). If you need 
this functionality use the pdflib module. 

Note: The function cpdf_set_font() has changed since PHP3 to support asian fonts. The encoding parameter 
is no longer an integer but a string. 

One big advantage of ClibPDF over pdflib is the possibility to create the pdf document completely in memory without 
using temporary files. It also provides the ability to pass coordinates in a predefined unit length. This is a handy feature 
but can be simulated with pdf_translate() . 

Most of the functions are fairly easy to use. The most difficult part is probably creating a very simple PDF document at 
all. The following example should help you get started. It creates a document with one page. The page contains the text 
"Times-Roman" in an outlined 30pt font. The text is underlined. 

Example 1, Simple ClibPDF Example 

<?php 

$cpdf = cpdf_open (0) ; 

cpdf_page_init ($cpdf , 1, 0, 595, 842); 

cpdf_add_outline ($cpdf , 0, 0, 0, 1, "Page 1"); 

cpdf_set_f ont ($cpdf , "Times-Roman", 30, "WinAnsiEncoding" ) ; 

cpdf_set_text_rendering ($cpdf , 1) ; 

cpdf_text ($cpdf , "Times Roman outlined", 50, 750); 

cpdf_moveto ($cpdf , 50, 740); 

cpdf_lineto ($cpdf, 330, 740); 

cpdf_stroke ($cpdf ) ; 

cpdf_f inalize ($cpdf ) ; 

Header ("Content-type : application/pdf " ) ; 

cpdf_output_buf fer ($cpdf ) ; 

cpdf_close ($cpdf ) ; 

?> 



The pdflib distribution contains a more complex example which creates a series of pages with an analog clock. Here is that 
example converted into PHP using the ClibPDF extension: 

Example 2, pdfclock example from pdflib 2.0 distribution 

<?php 

$radius = 200; 
$margin = 20; 
$pagecount = 40; 

$pdf = cpdf_open (0) ; 

cpdf_set_creator ($pdf , "pdf_clock .php3") ; 

cpdf_set_title ($pdf, "Analog Clock"); 

while ($pagecount — > 0) { 

cpdf_page_init ($pdf , $pagecount+l, 0, 2 * ($radius + $margin) , 2 * ($radius + 
$margin) , 1.0); 

cpdf_set_page_animation ($pdf , 4, 0.5, 0, 0, 0); /* wipe */ 

cpdf_translate ($pdf , $radius + $margin, $radius + $margin) ; 

cpdf_save ($pdf ) ; 

cpdf_setrgbcolor ($pdf, 0.0, 0.0, 1.0); 

/* minute strokes */ 

cpdf_setlinewidth ($pdf , 2.0); 

for ($alpha = 0; $alpha < 360; $alpha += 6) 

{ 

cpdf_rotate ($pdf , 6.0); 

cpdf_moveto ($pdf , $radius, 0.0); 

cpdf_lineto ($pdf , $radius-$margin/3, 0.0); 

cpdf_stroke ($pdf ) ; 

} 

cpdf_restore ($pdf ) ; 
cpdf_save ($pdf ) ; 

/* 5 minute strokes */ 

cpdf_setlinewidth ($pdf , 3.0); 

for ($alpha = 0; $alpha < 360; $alpha += 30) 

{ 

cpdf_rotate ($pdf , 30.0); 

cpdf_moveto ($pdf , $radius, 0.0); 

cpdf_lineto ($pdf , $radius-$margin, 0.0); 

cpdf_stroke ($pdf ) ; 
} 

$ltime = getdateO; 

/* draw hour hand */ 

cpdf_save ($pdf ) ; 

cpdf_rotate($pdf, -( ($ltime [ 'minutes '] /60 . 0) + $ltime [' hours ' ] - 3.0) * 30.0); 

cpdf_moveto ($pdf , -$radius/10, -$radius/20) ; 

cpdf_lineto ($pdf , $radius/2, 0.0); 

cpdf_lineto ($pdf , -$radius/10, $radius/20); 

cpdf_closepath ($pdf ) ; 

cpdf_fill ($pdf) ; 

cpdf_restore ($pdf ) ; 

/* draw minute hand */ 



cpdf_save ($pdf ) ; 

cpdf_rotate ($pdf, -( ($ltime [' seconds '] /60 . 0) + $ltime [ 'minutes ' ] - 15.0) * 6.0); 

cpdf_moveto ($pdf , -$radius/10, -$radius/20 ) ; 

cpdf_lineto ($pdf, $radius * 0.8, 0.0); 

cpdf_lineto ($pdf , -$radius/10, $radius/20); 

cpdf_closepath ($pdf ) ; 

cpdf_fill ($pdf) ; 

cpdf_restore ($pdf ) ; 

/* draw second hand */ 

cpdf_setrgbcolor ($pdf, 1.0, 0.0, 0.0); 

cpdf_setlinewidth ($pdf , 2); 

cpdf_save ($pdf ) ; 

cpdf_rotate ($pdf, -( ($ltime [' seconds ' ] - 15.0) * 6.0)); 

cpdf_moveto ($pdf , -$radius/5, 0.0); 

cpdf_lineto ($pdf , $radius, 0.0); 

cpdf_stroke ($pdf ) ; 

cpdf_restore ($pdf ) ; 

/* draw little circle at center */ 
cpdf_circle ($pdf , 0, 0, $radius/30); 
cpdf_fill ($pdf) ; 

cpdf_restore ($pdf ) ; 

cpdf_f inalize_page ($pdf , $pagecount+l) ; 



} 



cpdf_f inalize ($pdf ) ; 

Header ( "Content-type : applicat ion/pdf " ) ; 

cpdf_output_buf fer ($pdf ) ; 

cpdf_close ($pdf ) ; 

?> 

Table of Contents 

// cpdf set creator Sets the creator field in the pdf document 

// cpdf_set_title Sets the title field of the pdf document 

// cpdf set subject Sets the subject field of the pdf document 

// cpdf_set_keywords Sets the keywords field of the pdf document 

// cpdf_open Opens a new pdf document 

// cpdf close Closes the pdf document 

// cpdf_page_init Starts new page 

// cpdf finalize page Ends page 

// cpdf_finalize Ends document 

// cpdf output buffer Outputs the pdf document in memory buffer 

// cpdf_save_to_file Writes the pdf document into a file 

// cpdf set current page Sets current page 

// cpdf_begin_text Starts text section 

// cpdf end text Starts text section 

// cpdf_show Output text at current position 

// cpdf show xy Output text at position 

// cpdf text Output text with parameters 



// cpdf_set_font Select the current font face and size 

// cpdf set leading Sets distance between text lines 

// cpdf_set_text_rendering Determines how text is rendered 

// cpdf set horiz scaling Sets horizontal scaling of text 

// cpdf_set_text_rise Sets the text rise 

// cpdf set text matrix Sets the text matrix 

// cpdf_set_text_pos Sets text position 

// cpdf set char spacing Sets character spacing 

// cpdf_set_word_spacing Sets spacing between words 

// cpdf continue text Output text in next line 

// cpdf_stringwidth Returns width of text in current font 

// cpdf_save Saves current enviroment 

// cpdf restore Restores formerly saved enviroment 

// cpdf_translate Sets origin of coordinate system 

// cpdf scale Sets scaling 

// cpdf_rotate Sets rotation 

// cpdf setflat Sets flatness 

// cpdf_setlineioin Sets linejoin parameter 

// cpdf setlinecap Sets linecap aparameter 

// cpdf_setmiterlimit Sets miter limit 

// cpdf setlinewidth Sets line width 

// cpdf_setdash Sets dash pattern 

// cpdf moveto Sets current point 

// cpdf rmoveto Sets current point 

// cpdf_curveto Draws a curve 

// cpdf lineto Draws a line 

// cpdf_rlineto Draws a line 

// cpdf circle Draw a circle 

// cpdf_arc Draws an arc 

// cpdf rect Draw a rectangle 

// cpdf_closepath Close path 

// cpdf stroke Draw line along path 

// cpdf_closepath_stroke Close path and draw line along path 

// cpdf fill Fill current path 

// cpdf_fill_stroke Fill and stroke current path 

// cpdf_closepath_fill_stroke Close, fill and stroke current path 

// cpdf clip Clips to current path 

// cpdf_setgrav_fill Sets filling color to gray value 

// cpdf setgray stroke Sets drawing color to gray value 

// cpdf_setgray Sets drawing and filling color to gray value 

// cpdf setrgbcolor fill Sets filling color to rgb color value 

// cpdf_setrgbcolor_stroke Sets drawing color to rgb color value 

// cpdf setrgbcolor Sets drawing and filling color to rgb color value 



// cpdf add outline Adds bookmark for current page 
// cpdf_set_page_animation Sets duration between pages 
// cpdf import jpeg Opens a JPEG image 
// cpdf_place_inline_image Places an image on the page 
// cpdf add annotation Adds annotation 



Prev Home Next 

easter_days Up cpdf_set_creator 



PHP Manual 

Prev Next 



VIM. Compression functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



This module uses the functions of zlib by Jean-loup Gailly and Mark Adler to transparently read 
and write gzip (.gz) compressed files. You have to use a zlib version >= 1.0.9 with this module. 

This module contains versions of most of the filesystem functions which work with 
gzip-compressed files (and uncompressed files, too, but not with sockets). 



Smail code example 



opens a temporary file and writes a test string to it, then it prints out the content of this file twice. 
Example 1. Small Zlib example 

<?php 

$f ilename = tempnam ( ' /tmp ' , ' zlibtest ' ) . ' . gz ' ; 
print "<html>\n<head></head>\n<body>\n<pre>\n" ; 

$s = "Only a test, test, test, test, test, test, test, test!\n"; 
// open file for writing with maximum compression 
$zp = gzopen ( $f ilename, "w9"); 
// write string to file 
gzwrite($zp, $s); 
// close file 
gzclose ( $zp) ; 
// open file for reading 
$zp = gzopen ($f ilename, "r"); 
// read 3 char 
print gzread($zp, 3); 

// output until end of the file and close it. 
gzpassthru ($zp) ; 
print "\n"; 

// open file and print content (the 2nd time) . 
if (readgzf lie ($f ilename) != strlen($s)) { 
echo "Error with zlib functions!"; 
} 



unlink ($filename) ; 

print "<pre>\n</hl></body>\n</html>\n" ; 
?> 

Table of Contents 

// gzclose close an open gz-file pointer 

// gzeof test for end-of-file on a gz-file pointer 

// gzfile read entire gz-file into an array 

// gzgetc get character from gz-file pointer 

// gzgets get line from file pointer 

// gzgetss get line from gz-file pointer and strip HTML tags 

// gzopen open gz-file 

// gzpassthru output all remaining data on a gz-file pointer 

// gzputs write to a gz-file pointer 

// gzread Binary-safe gz-file read 

// gzrewind rewind the position of a gz-file pointer 

// gzseek seek on a gz-file pointer 

// gztell tell gz-file pointer read/write position 

// gzwrite Binary- safe gz-file write 

// readgzfile output a gz-file 



Prev Home Next 

cpdf_add_annotation Ug gzclose 



PHP Manual 

Prev Next 



IX. Database (dbm-style) abstraction 
layer functions 



These functions are not suppc 

PHP Lite edition. 

Look at the functions manual-page to 

^^^ossibl^wo^araun^xists™ 




These functions build the foundation for accessing Berkeley DB style databases. 

This is a general abstraction layer for several file-based databases. As such, functionality is limited 
to a subset of features modern databases such as Sleepycat Software's DB2 support. (This is not to 
be confused with IBM's DB2 software, which is supported through the ODBC functions .) 

The behaviour of various aspects depend on the implementation of the underlying database. 
Functions such as dba_optimize() and dba_sync() will do what they promise for one database and 
will do nothing for others. 

The following handlers are supported: 

q dbm is the oldest (original) type of Berkeley DB style databases. You should avoid it, if 
possible. We do not support the compatibility functions built into DB2 and gdbm, because 
they are only compatible on the source code level, but cannot handle the original dbm format. 

q ndbm is a newer type and more flexible than dbm. It still has most of the arbitrary limits of 
dbm (therefore it is deprecated). 

q gdbm is the GNU database manager. 

q db2 is Sleepycat Software's DB2. It is described as "a programmatic toolkit that provides 
high-performance built-in database support for both standalone and client/server 
applications." 

q cdb is "a fast, reliable, lightweight package for creating and reading constant databases." It is 
from the author of qmail and can be found here. Since it is constant, we support only reading 
operations. 



Example 1. DBA example 

<?php 

$id = dba_open ("/tmp/test .db", "n", "db2"); 

if(!$id) { 

echo "dba_open failed\n"; 

exit ; 
} 

dba_replace ( "key" , "This is an example!", $id) ; 

if (dba_exists ("key", $id) ) { 

echo dba_f etch ( "key" , $id) ; 
dba_delete ( "key" , $id) ; 

} 

dba_close ($id) ; 
?> 

DBA is binary safe and does not have any arbitrary limits. It inherits all limits set by the underlying 
database implementation. 

All file-based databases must provide a way of setting the file mode of a new created database, if 
that is possible at all. The file mode is commonly passed as the fourth argument to dba_open() or 
dba_popen(). 

You can access all entries of a database in a linear way by using the dba_firstkey() and 
dba_nextkey() functions. You may not change the database while traversing it. 

Example 2. Traversing a database 

<?php 

# . . .open database. . . 

$key = dba_f irstkey ($id) ; 

while ($key != false) { 

if ( . . . ) { # remember the key to perform some action later 
$handle_later [ ] = $key; 

} 

$key = dba_nextkey ($id) ; 

} 

for($i = 0; $i < count ($handle_later) ; $i++) 
dba_delete ( $handle_later [ $i] , $id) ; 

?> 



Table of Contents 

// dba_close Close database 

// dba_delete Delete entry specified by key 

// dba_exists Check whether key exists 

// dba_fetch Fetch data specified by key 

// dba_firstkey Fetch first key 

// dba_insert Insert entry 

// dba_nextkev Fetch next key 

// dba_popen Open database persistently 

// dba_open Open database 

// dba_optimize Optimize database 

// dba_replace Replace or insert entry 

// dba_sync Synchronize database 

Prev Home Next 

readgzfile Up dba_close 



PHP Manual 

Prev Next 



X. Date and Time functions 

Table of Contents 

// checkdate validate a date/time 

date f ormat a local time/date 

getdate get date/time information 

gettimeofday get current time 

// gmdate format a GMT/CUT date/time 

// gmmktime get UNIX timestamp for a GMT date 

gmstrftime format a GMT/CUT time/date according to locale settings 

microtime return current UNIX timestamp with microseconds 

// mktime get UNIX timestamp for a date 

strftime format a local time/date according to locale settings 

time return current UNIX timestamp 

Prev Home Next 

dba_sync Up checkdate 



PHP Manual 

Prev Next 



XI. dBase functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions allow you to access records stored in dBase-format (dbf) databases. 

There is no support for indexes or memo fields. There is no support for locking, too. Two 
concurrent webserver processes modifying the same dBase file will very likely ruin your database. 

Unlike SQL databases, dBase "databases" cannot change the database definition afterwards. Once 
the file is created, the database definition is fixed. There are no indexes that speed searching or 
otherwise organize your data. dBase files are simple sequential files of fixed length records. 
Records are appended to the end of the file and delete records are kept until you call 
dbase_pack()(). 

We recommend that you do not use dBase files as your production database. Choose any real SQL 
server instead; MySQL or Postgres are common choices with PHP. dBase support is here to allow 
you to import and export data to and from your web database, since the file format is commonly 
understood with Windows spreadsheets and organizers. Import and export of data is about all that 
dBase support is good for. 

Table of Contents 

// dbase_create creates a dBase database 

// dbase_open opens a dBase database 

// dbase_close close a dBase database 

// dbase_pack packs a dBase database 

// dbase_add_record add a record to a dBase database 

// dbase_replace_record replace a record in a dBase database 

// dbase_delete_record deletes a record from a dBase database 

// dbase_get_record gets a record from a dBase database 

// dbase_get_record_with_names gets a record from a dBase database as an associative array 

// dbase_numfields find out how many fields are in a dBase database 

// dbase_numrecords find out how many records are in a dBase database 



Prev Home Next 

time Up dbase_create 



PHP Manual 

Prev Next 



XII. dbm functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions allow you to store records stored in a dbm-style database. This type of database 
(supported by the Berkeley db, gdbm, and some system libraries, as well as a built-in flatfile 
library) stores key/value pairs (as opposed to the full-blown records supported by relational 
databases). 

Example 1. dbm example 

$dbm = dbmopen ( "last seen" , "w"); 
if (dbmexists ( $dbm, $userid) ) { 

$last_seen = dbmf etch ($ dbm, $userid) ; 
} else { 

dbminsert ( $dbm, $userid, time()); 

} 

do_stuf f ( ) ; 

dbmreplace ($dbm, $userid, timeO); 

dbmclose ($dbm) ; 

Table of Contents 

// dbmopen opens a dbm database 

// dbmclose closes a dbm database 

// dbmexists tells if a value exists for a key in a dbm database 

// dbmfetch fetches a value for a key from a dbm database 

// dbminsert inserts a value for a key in a dbm database 

// dbmreplace replaces the value for a key in a dbm database 

// dbmdelete deletes the value for a key from a dbm database 

// dbmfirstkey retrieves the first key from a dbm database 

// dbmnextkey retrieves the next key from a dbm database 

// dblist describes the dbm-compatible library being used 

Prev Home Next 

dbase_numrecords Up dbmopen 



PHP Manual 

Prev Next 



XIII. Directory functions 

Table of Contents 

chdir change directory 

dir directory class 

closedir close directory handle 

opendir open directory handle 

readdir read entry from directory handle 

rewinddir rewind directory handle 

Prev Home Next 

dblist Up chdir 



PHP Manual 

Prev Next 



XVIII. Forms Data Format functions 




[These functions are not supported in tb 

PHP Lite edition. 
[Look at the functions manual-page to 

^ee if possible workaround exists. 



Forms Data Format (FDF) is a format for handling forms within PDF documents. You should read 
the documentation at http://partners.adobe.com/asn/developer/acrosdk/forms.html for more 

information on what FDF is and how it is used in general. 

Note: Currently Adobe only provides a libc5 compatible version for Linux. Tests with 
glibc2 resulted in a segmentation fault. If somebody is able to make it work, please 
comment on this page. 

Note: If you run into problems configuring php with fdftk support, check whether the 
header file FdfTk.h and the library libFdfTk.so are at the right place. They should be in 
fdftk-dir/include and fdftk-dir/lib. This will not be the case if you just unpack the 
FdfTk distribution. 

The general idea of FDF is similar to HTML forms. The diffence is basically the format how filled 
in data is transmitted to the server when the submit button is pressed (this is actually the Form Data 
Format) and the format of the form itself (which is the Portable Document Format, PDF). 
Processing the FDF data is one of the features provided by the fdf functions. But there is more. One 
may as well take an existing PDF form and populated the input fields with data without modifying 
the form itself. In such a case one would create a FDF document ( fdf_create() ) set the values of 
each input field ( fdf_set_value() ) and associate it with a PDF form ( fdf_set_file() ). Finally it has to 
be sent to the browser with MimeType application/vnd.fdf. The Acrobat reader plugin of your 
browser recognizes the MimeType, reads the associated PDF form and fills in the data from the 
FDF document. 

The following examples shows just the evaluation of form data. 



Example 1. Evaluating a FDF document 

<?php 

// Save the FDF data into a temp file 

$fdffp = f open ( "test. fdf", "w"); 

fwrite ($fdffp, $HTTP_FDF_DATA, strlen ( $HTTP_FDF_DATA) ) ; 

fclose ($fdf fp) ; 

// Open temp file and evaluate data 

// The pdf form contained several input text fields with the names 

// volume, date, comment, publisher, preparer, and two checkboxes 

// show_publisher and show_preparer . 

$fdf = fdf_open("test.fdf") ; 

$volume = f df_get_value ( $f df , "volume"); 

echo "The volume field has the value ' <B>$volume</B> ' <BR>" ; 

$date = f df_get_value ($f df , "date"); 

echo "The date field has the value ' <B>$date</B> ' <BR>" ; 

$comment = f df_get_value ($f df , "comment"); 

echo "The comment field has the value ' <B>$comment</B> ' <BR>" ; 

if (fdf_get_value ($fdf , "show_publisher" ) == "On") { 

$publisher = f df_get_value ( $f df , "publisher"); 

echo "The publisher field has the value ' <B>$publisher</B> ' <BR>" ; 
} else 

echo "Publisher shall not be shown. <BR>"; 

if (f df_get_value ( $f df , "show_preparer " ) == "On") { 

$preparer = f df_get_value ($f df , "preparer"); 

echo "The preparer field has the value ' <B>$preparer</B> ' <BR>" ; 
} else 

echo "Preparer shall not be shown. <BR>"; 
fdf_close ($fdf ) ; 
?> 

Table of Contents 

// fdf_open Open a FDF document 

// fdf_close Close an FDF document 

// fdf_create Create a new FDF document 

// fdf_save Save a FDF document 

// fdf_get_value Get the value of a field 

// fdf_set_value Set the value of a field 

// fdf_next_field_name Get the next field name 

// fdf_set_ap Set the appearance of a field 



// fdf_set_status Set the value of the /STATUS key 
//fdf get status Get the value of the /STATUS key 
// fdf_set_file Set the value of the /F key 
// fdf_get_file Get the value of the /F key 

Prev Home Next 

unlink U^ fdf_open 



PHP Manual 

Prev Next 



XIX. FTP functions 

FTP stands for File Transfer Protocol. 

The following constants are defined when using the FTP module: FTP_ASCII, and FTP_BINARY. 
Table of Contents 

ftp_connect Opens up an FTP connection 

ftp_login Logs in an FTP connection 

ftp_pwd Returns the current directory name 

ftp_cdup Changes to the parent directory 

ftp_chdir Changes directories on a FTP server 

ftp_mkdir Creates a directory 

ftp_rmdir Removes a directory 

ftp_nlist Returns a list of files in the given directory. 

ftp_rawlist Returns a detailed list of files in the given directory. 

ftp_systype Returns the system type identifier of the remote FTP server. 

ftp_pasv Turns passive mode on or off. 

ftp_get Downloads a file from the FTP server. 

ftp_fget Downloads a file from the FTP server and saves to an open file. 

ftp_put Uploads a file to the FTP server. 

ftp_fput Uploads from an open file to the FTP server. 

ftp_size Returns the size of the given file. 

ftp_mdtm Returns the last modified time of the given file. 

ftp_rename Renames a file on the ftp server. 

ftp_delete Deletes a file on the ftp server. 

ftp_quit Closes an FTP connection 

Prev Home Next 

fdf_get_file Ug ftp_connect 



PHP Manual 

Prev Next 



XX. Hash functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions are intended to work with mhash . 

This is an interface to the mhash library, mhash supports a wide variety of hash algorithms such as 
MD5, SHAl, GOST, and many others. 

To use it, download the mhash distribution from its web site and follow the included installation 
instructions. You need to compile PHP with the — with-mhash parameter to enable this 
extension. 

mhash can be used to create checksums, message digests, and more. 

Example 1. Compute the SHAl key and print it out as hex 

<?php 

$input = "Let us meet at 9 o ' clock at the secret place."; 

$hash = mhash (MHASH_SHA1, $input); 

print "The hash is " .bin2hex ($hash) ."\n"; 

?> 

This will produce: 

The hash is d3b85d710d8f 6e4e5ef d4d5e67d041f 9cecedaf e 

For a complete list of supported hashes, refer to the documentation of mhash. The general rule is 
that you can access the hash algorithm from PHP with MHASH_HASHNAME. For example, to 
access HAVAL you use the PHP constant MHASH_HAVAL. 

Here is a list of hashes which are currently supported by mhash. If a hash is not listed here, but is 
listed by mhash as supported, you can safely assume that this documentation is outdated. 

q MHASH_MD5 

q MHASH_SHA1 

q MHASH_HAVAL 



q MHASH_RIPEMD160 

q MHASH_RIPEMD128 

q MHASH_SNEFRU 

q MHASH_TIGER 

q MHASH_GOST 

q MHASH_CRC32 

q MHASH_CRC32B 
Table of Contents 

// mhash_get_hash_name Get the name of the specified hash 
// mhash_get_block_size Get the block size of the specified hash 
// mhash_count Get the highest available hash id 
// mhash Compute hash 



Prev Home Next 

ftp_quit Up mhash_get_hash_name 



PHP Manual 

Prev Next 



XXI. HTTP functions 



These functions let you manipulate the output sent back to the remote browser right down to the 
HTTP protocol level. 

Table of Contents 

header Send a raw HTTP header 

setcookie Send a cookie 

Prev Home Next 

mhash Up header 



PHP Manual 

Prev Next 



XXII. Hyperwave functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



Introduction 



Hyperwave has been developed at IICM in Graz. It started with the name Hyper-G and changed to 
Hyperwave when it was commercialised (If I remember properly it was in 1996). 

Hyperwave is not free software. The current version, 4.1, is available at www.hyperwave.com . A 
time limited version can be ordered for free (30 days). 

Hyperwave is an information system similar to a database (HIS, Hyperwave Information Server). 
Its focus is the storage and management of documents. A document can be any possible piece of 
data that may as well be stored in file. Each document is accompanied by its object record. The 
object record contains meta data for the document. The meta data is a list of attributes which can be 
extended by the user. Certain attributes are always set by the Hyperwave server, other may be 
modified by the user. An attribute is a name/value pair of the form name=value. The complete 
object record contains as many of those pairs as the user likes. The name of an attribute does not 
have to be unique, e.g. a title may appear several times within an object record. This makes sense if 
you want to specify a title in several languages. In such a case there is a convention, that each title 
value is preceded by the two letter language abbreviation followed by a colon, e.g. 'en:Title in 
English' or 'ge:Titel in deutsch'. Other attributes like a description or keywords are potential 
candidates. You may also replace the language abbreviation by any other string as long as it 
separated by colon from the rest of the attribute value. 

Each object record has native a string representation with each name/value pair separated by a 
newline. The Hyperwave extension also knows a second representation which is an associated array 
with the attribute name being the key. Multilingual attribute values itself form another associated 
array with the key being the language abbreviation. Actually any multiple attribute forms an 
associated array with the string left to the colon in the attribute value being the key. (This is not 
fully implemented. Only the attributes Title, Description and Keyword are treated properly yet.) 

Besides the documents, all hyper links contained in a document are stored as object records as well. 
Hyper links which are in a document will be removed from it and stored as individual objects, when 
the document is inserted into the database. The object record of the link contains information about 



where it starts and where it ends. In order to gain the original document you will have to retrieve 
the plain document without the links and the list of links and reinsert them (The functions 
hw_pipedocument() and hw_gettext() do this for you. The advantage of separating links from the 
document is obvious. Once a document to which a link is pointing to changes its name, the link can 
easily be modified accordingly. The document containing the link is not affected at all. You may 
even add a link to a document without modifying the document itself. 

Saying that hw_pipedocument() and hw_gettext() do the link insertion automatically is not as 
simple as it sounds. Inserting links implies a certain hierarchy of the documents. On a web server 
this is given by the file system, but Hyperwave has its own hierarchy and names do not reflect the 
position of an object in that hierarchy. Therefore creation of links first of all requires a mapping 
from the Hyperwave hierarchy and namespace into a web hierarchy respective web namespace. The 
fundamental difference between Hyperwave and the web is the clear distinction between names and 
hierarchy in Hyperwave. The name does not contain any information about the objects position in 
the hierarchy. In the web the name also contains the information on where the object is located in 
the hierarchy. This leads to two possibles ways of mapping. Either the Hyperwave hierarchy and 
name of the Hyperwave object is reflected in the URL or the name only. To make things simple the 
second approach is used. Hyperwave object with name 'my_object' is mapped to 
'http://host/my_object' disregarding where it resides in the Hyperwave hierarchy. An object with 
name 'parent/my _object' could be the child of 'my_object' in the Hyperwave hierarchy, though in a 
web namespace it appears to be just the opposite and the user might get confused. This can only be 
prevented by selecting reasonable object names. 

Having made this decision a second problem arises. How do you involve PHP? The URL 
http://host/my_object will not call any PHP script unless you tell your web server to rewrite it to 
e.g. 'http://host/php3_script/my_object' and the script 'php3_script' evaluates the $PATH_INFO 
variable and retrieves the object with name 'my_object' from the Hyperwave server. Their is just 
one little drawback which can be fixed easily. Rewriting any URL would not allow any access to 
other document on the web server. A PHP script for searching in the Hyperwave server would be 
impossible. Therefore you will need at least a second rewriting rule to exclude certain URLS like 
all e.g. starting with http://host/Hyperwave. This is basically sharing of a namespace by the web 
and Hyperwave server. 

Based on the above mechanism links are insert into documents. 

It gets more complicated if PHP is not run as a server module or CGI script but as a standalone 
application e.g. to dump the content of the Hyperwave server on a CD-ROM. In such a case it 
makes sense to retain the Hyperwave hierarchy and map in onto the file system. This conflicts with 
the object names if they reflect its own hierarchy (e.g. by choosing names including '/'). Therefore 
'/' has to be replaced by another character, e.g. '_'. to be continued. 

The network protocol to communicate with the Hyperwave server is called HG-CSP (Hyper-G 
Client/Server Protocol). It is based on messages to initiate certain actions, e.g. get object record. In 
early versions of the Hyperwave Server two native clients (Harmony, Amadeus) were provided for 
communication with the server. Those two disappeared when Hyperwave was commercialised. As 
a replacement a so called wavemaster was provided. The wavemaster is like a protocol converter 
from HTTP to HG-CSP. The idea is to do all the administration of the database and visualisation of 
documents by a web interface. The wavemaster implements a set of placeholders for certain actions 
to customise the interface. This set of placeholders is called the PLACE Language. PLACE lacks a 



lot of features of a real programming language and any extension to it only enlarges the list of 
placeholders. This has led to the use of JavaScript which IMO does not make life easier. 

Adding Hyperwave support to PHP should fill in the gap of a missing programming language for 
interface customisation. It implements all the messages as defined by the HG-CSP but also provides 
more powerful commands to e.g. retrieve complete documents. 

Hyperwave has its own terminology to name certain pieces of information. This has widely been 
taken over and extended. Almost all functions operate on one of the following data types. 

q object ID: An unique integer value for each object in the Hyperwave server. It is also one of 
the attributes of the object record (ObjectID). Object ids are often used as an input parameter 
to specify an object. 

q object record: A string with attribute- value pairs of the form attribute^ value. The pairs are 
separated by a carriage return from each other. An object record can easily be converted into 
an object array with hw_object2array(). Several functions return object records. The names 
of those functions end with obj . 

q object array: An associated array with all attributes of an object. The key is the attribute 
name. If an attribute occurs more than once in an object record it will result in another 
indexed or associated array. Attributes which are language depended (like the title, keyword, 
description) will form an associated array with the key set to the language abbreviation. All 
other multiple attributes will form an indexed array. PHP functions never return object 
arrays. 

q hw_document: This is a complete new data type which holds the actual document, e.g. 
HTML, PDF etc. It is somewhat optimised for HTML documents but may be used for any 
format. 

Several functions which return an array of object records do also return an associated array with 
statistical information about them. The array is the last element of the object record array. The 
statistical array contains the following entries: 

Hidden 

Number of object records with attribute PresentationHints set to Hidden. 
CollectionHead 

Number of object records with attribute PresentationHints set to CollectionHead. 
FullCollectionHead 

Number of object records with attribute PresentationHints set to FullCollectionHead. 
CollectionHeadNr 

Index in array of object records with attribute PresentationHints set to CollectionHead. 
FullCollectionHeadNr 

Index in array of object records with attribute PresentationHints set to FullCollectionHead. 
Total 

Total: Number of object records. 



Integration with Apache 

The Hyperwave extension is best used when PHP is compiled as an Apache module. In such a case 
the underlying Hyperwave server can be hidden from users almost completely if Apache uses its 
rewriting engine. The following instructions will explain this. 

Since PHP with Hyperwave support built into Apache is intended to replace the native Hyperwave 
solution based on Wavemaster I will assume that the Apache server will only serve as a Hyperwave 
web interface. This is not necessary but it simplifies the configuration. The concept is quite simple. 
First of all you need a PHP script which evaluates the PATH_INF0 variable and treats its value as 
the name of a Hyperwave object. Let's call this script 'Hyperwave'. The URL 
http://your.hostname/Hyperwave/name_of_object would than return the Hyperwave object with the 
name 'name_of_object'. Depending on the type of the object the script has to react accordingly. If it 
is a collection, it will probably return a list of children. If it is a document it will return the mime 
type and the content. A slight improvement can be achieved if the Apache rewriting engine is used. 
From the users point of view it would be more straight forward if the URL 
http://your.hostname/name_of_object would return the object. The rewriting rule is quite easy: 

RewriteRule ^/(.*) /usr/local/apache/htdocs/HyperWave/$l [L] 

Now every URL relates to an object in the Hyperwave server. This causes a simple to solve 
problem. There is no way to execute a different script, e.g. for searching, than the 'Hyperwave' 
script. This can be fixed with another rewriting rule like the following: 

RewriteRule ■^/hw/(.*) /usr/local/apache/htdocs/hw/$l [L] 

This will reserve the directory /usr/local/apache/htdocs/hw for additional scripts and 
other files. Just make sure this rule is evaluated before the one above. There is just a little 
drawback: all Hyperwave objects whose name starts with 'hw/' will be shadowed. So, make sure 
you don't use such names. If you need more directories, e.g. for images just add more rules or place 
them all in one directory. Finally, don't forget to turn on the rewriting engine with 

RewriteEngine on 

My experiences have shown that you will need the following scripts: 

q to return the object itself 

q to allow searching 

q to identify yourself 

q to set your profile 

q one for each additional function like to show the object attributes, to show information about 
users, to show the status of the server, etc. 



Todo 



There are still some things todo: 

q The hw_InsertDocument has to be split into hw_InsertObject() and hw_PutDocument(). 

q The names of several functions are not fixed, yet. 

q Most functions require the current connection as its first parameter. This leads to a lot of 
typing, which is quite often not necessary if there is just one open connection. A default 
connection will improve this. 

q Conversion form object record into object array needs to handle any multiple attribute. 
Table of Contents 

// hw_Array20birec convert attributes from object array to object record 
// hw_Children object ids of children 
// hw_ChildrenObi object records of children 
// hw_Close closes the Hyperwave connection 
// hw_Connect opens a connection 
// hw_Cp copies objects 
// hw_Deleteobiect deletes object 

// hw_DocBy Anchor object id object belonging to anchor 
// hw_DocByAnchorObi object record object belonging to anchor 
// hw_DocumentAttributes object record of hw_document 
// hw_DocumentBodyTag body tag of hw_document 
// hw_DocumentContent returns content of hw_document 
// hw_DocumentSetContent sets/replaces content of hw_document 
// hw_DocumentSize size of hw_document 
// hw_ErrorMsg returns error message 
// hw_EditText retrieve text document 
// hw_Error error number 
// hw_Free_Document frees hw_document 
// hw_GetParents object ids of parents 
// hw_GetParentsObi object records of parents 
// hw_GetChildColl object ids of child collections 
// hw_GetChildCollObi object records of child collections 
// hw_GetRemote Gets a remote document 
// hw GetRemoteChildren Gets children of remote document 



// hw_GetSrcByDestObi Returns anchors pointing at object 

// hw_GetObiect object record 

// hw_GetAndLock return bject record and lock object 

// hw_GetText retrieve text document 

// hw_GetObiectBy Query search object 

// hw_GetObiectBy Query Obi search object 

// hw_GetObiectBy Query Coll search object in collection 

// hw_GetObiectBy Query CollObj search object in collection 

// hw_GetChildDocColl object ids of child documents of collection 

// hw_GetChildDocCollObi object records of child documents of collection 

// hw_GetAnchors object ids of anchors of document 

// hw_GetAnchorsObi object records of anchors of document 

// hw_Mv moves objects 

// hw_Identify identifies as user 

// hw_InCollections check if object ids in collections 

// hw_Info info about connection 

// hw_InsColl insert collection 

// hw_InsDoc insert document 

// hw_InsertDocument upload any document 

// hw_InsertObiect inserts an object record 

// hw_mapid Maps global id on virtual local id 

// hw_Modify object modifies object record 

// hw_New_Document create new document 

// hw_0birec2Array convert attributes from object record to object array 

// hw_OutputDocument prints hw_document 

// hw_pConnect make a persistent database connection 

// hw_PipeDocument retrieve any document 

// hw_Root root object id 

// hw_Unlock unlock object 

// hw_Who List of currently logged in users 

// hw_Username name of currently logged in user 

Prev Home Next 

setcookie Ug hw_Array20bjrec 



PHP Manual 

Prev Next 



XXIII. Image functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



You can use the image functions in PHP to get the size of JPEG, GIF, and PNG images, and if you 

have the GD library (available at http://www.boutell.com/gd/) you will also be able to create and 

manipulate images. 

Table of Contents 

// GetlmageSize get the size of a GIF, JPG or PNG image 

// Image Arc draw a partial ellipse 

// ImageChar draw a character horizontally 

// ImageCharUp draw a character vertically 

// ImageColorAllocate allocate a color for an image 

// ImageColorAt get the index of the color of a pixel 

// ImageColorClosest get the index of the closest color to the specified color 

// ImageColorExact get the index of the specified color 

// ImageColorResolve get the index of the specified color or its closest possible alternative 

// ImageColorSet set the color for the specified palette index 

// ImageColorsForlndex get the colors for an index 

// ImageColorsTotal find out the number of colors in an image's palette 

// ImageColorTransparent define a color as transparent 

// ImageCopyResized copy and resize part of an image 

// ImageCreate create a new image 

// ImageCreateFromGif create a new image from file or URL 

// ImageDashedLine draw a dashed line 

// ImageDestroy destroy an image 

// ImageFill flood fill 

// ImageFilledPolygon draw a filled polygon 



// ImageFilledRectangle draw a filled rectangle 

// ImageFillToB order flood fill to specific color 

// ImageFontHeight get font height 

// ImageFontWidth get font width 

// ImageGif output image to browser or file 

// Imagelnterlace enable or disable interlace 

// ImageLine draw a line 

// ImageLoadFont load a new font 

// ImagePolygon draw a polygon 

// ImagePSBBox give the bounding box of a text rectangle using PostScript Typel fonts 

// ImagePSEncodeFont change the character encoding vector of a font 

// ImagePSFreeFont free memory used by a PostScript Type 1 font 

// ImagePSLoadFont load a PostScript Type 1 font from file 

// ImagePSText to draw a text string over an image using PostScript Typel fonts 

// ImageRectangle draw a rectangle 

// ImageSetPixel set a single pixel 

// ImageString draw a string horizontally 

// ImageStringUp draw a string vertically 

// ImageSX get image width 

// Images Y get image height 

// ImageTTFBBox give the bounding box of a text using TypeType fonts 

// ImageTTFText write text to the image using TrueType fonts 

Prev Home Next 

hw_Username Up GetlmageSize 



PHP Manual 

Prev Next 



XXIV. IMAP functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



To get these functions to work, you have to compile PHP with — with-imap. That requires the 
c-client library to be installed. Grab the latest version from ftp://ftp.cac.washington.edu/imap/ and 
compile it. Then copy c-client/c-client.a to /usr/local/lib or some other directory on your link path 
and copy c-client/rfc822.h, mail.h and linkage.h to /usr/local/include or some other directory in 
your include path. 

Note that these functions are not limited to the IMAP protocol, despite their name. The underlying 

c-client library also supports NNTP, POPS and local mailbox access methods. See the imap_open() 

for more information. 

Table of Contents 

// imap_append Append a string message to a specified mailbox 

// imap_base64 Decode BASE64 encoded text 

// imap_bodv Read the message body 

// imap_check Check current mailbox 

// imap_close Close an IMAP stream 

// imap_createmailbox Create a new mailbox 

// imap_delete Mark a messge for deletion from current mailbox 

// imap_deletemailbox Delete a mailbox 

// imap_expunge Delete all messages marked for deletion 

// imap_fetchbody Fetch a particular section of the body of the message 

// imap_fetchstructure Read the structure of a particular message 

// imap_header Read the header of the message 

// imap_headers Returns headers for all messages in a mailbox 

// imap_listmailbox Read the list of mailboxes 

// imap_getmailboxes Read the list of mailboxes, returning detailed information on each one 

// imap_listsubscribed List all the subscribed mailboxes 



// imap_getsubscribed List all the subscribed mailboxes 

// imap_mail_copy Copy specified messages to a mailbox 

// imap_mail_move Move specified messages to a mailbox 

// imap_num_msg Gives the number of messages in the current mailbox 

// imap_num_recent Gives the number of recent messages in current mailbox 

// imap_open Open an IMAP stream to a mailbox 

// imap_ping Check if the IMAP stream is still active 

// imap_renamemailbox Rename an old mailbox to new mailbox 

// imap_reopen Reopen IMAP stream to new mailbox 

// imap_subscribe Subscribe to a mailbox 

// imap_undelete Unmark the message which is marked deleted 

// imap_unsubscribe Unsubscribe from a mailbox 

// imap_qprint Convert a quoted-printable string to an 8 bit string 

// imap_8bit Convert an Sbit string to a quoted-printable string. 

// imap_binary Convert an Sbit string to a base64 string. 

// imap_scanmailbox Read the list of mailboxes, takes a string to search for in the text of the 

mailbox 

// imap_mailboxmsginfo Get information about the current mailbox 

// imap_rfc822_write_address Returns a properly formatted email address given the mailbox, host, 

and personal info. 

// imap_rfc822_parse_adrlist Parses an address string 

// imap_setflag_full Sets flags on messages 

// imap_clearflag_full Clears flags on messages 

// imap_sort 

// imap_fetchheader Returns header for a message 

// imap_uid This function returns the UID for the given message sequence number. 

// imap_msgno This function returns the message sequence number for the given UID. 

// imap_search This function returns an array of messages matching the given search criteria. 

// imap_last_error This function returns the last IMAP error (if any) that occurred during this page 

request. 

// imap_errors This function returns all of the IMAP errors (if any) that have occurred during this 

page request or since the error stack was reset. 

// imap_alerts This function returns all IMAP alert messages (if any) that have occurred during 

this page request or since the alert stack was reset. 

// imap_status This function returns status information on a mailbox other than the current one. 



Prev Home Next 

ImageTTFText Ug imap_append 



PHP Manual 

Prev Next 



XXVI. InterBase functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 

Table of Contents 

ibase connect 



XX 111 lllV ~ 

geto I 



ibase_pconnect 



ibase close 



ibase_query 



ibase fetch row 



ibase free result 



ibase_prepare 



ibase bind 



ibase execute 



ibase_free_query 



ibase timefmt 



Prev Home Next 

ifxus_write_slob Up ibase_connect 



PHP Manual 

Prev Next 



XXVII. LDAP functions 




Ihese functioni 
HP Lite edition, 
ook at the functions manual-page to 
ie if possible workaround exists. 



Introduction to LDAP 

LDAP is the Lightweight Directory Access Protocol, and is a protocol used to access "Directory Servers". The 
Directory is a special kind of database that holds information in a tree structure. 

The concept is similar to your hard disk directory structure, except that in this context, the root directory is "The 
world" and the first level subdirectories are "countries". Lower levels of the directory structure contain entries for 
companies, organisations or places, while yet lower still we find directory entries for people, and perhaps 
equipment or documents. 

To refer to a file in a subdirectory on your hard disk, you might use something like 

/usr/local/myapp/docs 

The forwards slash marks each division in the reference, and the sequence is read from left to right. 

The equivalent to the fully qualified file reference in LDAP is the "distinguished name", referred to simply as 
"dn". An example dn might be. 

cn=John Smith,ou=Accounts,o=My Company,c=US 

The comma marks each division in the reference, and the sequence is read from right to left. You would read this 
dn as .. 

country = US 

organization = My Company 
organizationalUnit = Accounts 
commonName = John Smith 

In the same way as there are no hard rules about how you organise the directory structure of a hard disk, a 
directory server manager can set up any structure that is meaningful for the purpose. However, there are some 
conventions that are used. The message is that you can not write code to access a directory server unless you 
know something about its structure, any more than you can use a database without some knowledge of what is 
available. 



Complete code example 



Retrieve information for all entries where the surname starts with "S" from a directory server, displaying an 
extract with name and email address. 

Example 1. LDAP search example 

<?php 

// basic sequence with LDAP is connect, bind, search, interpret search 

// result, close connection 

echo "<h3>LDAP query test</h3>"; 

echo "Connecting . . . " ; 

$ds=ldap_connect ( "localhost " ) ; // must be a valid LDAP server! 

echo "connect result is " . $ds . "<p>" ; 

if ($ds) { 

echo "Binding . . . " ; 

$r=ldap_bind ( $ds ) ; // this is an "anonymous" bind, typically 

// read-only access echo "Bind result is 
echo "Bind result is ".$r."<p>"; 

echo "Searching for (sn=S*) ..."; 

// Search surname entry 

$sr=ldap_search ( $ds, "o=My Company, c=US", "sn=S*"); 

echo "Search result is " . $sr . "<p>" ; 

echo "Number of entires returned is " . ldap_count_entries ( $ds, $sr) ."<p>"; 

echo "Getting entries ...<p>"; 

$info = ldap_get_entries ( $ds, $sr) ; 

echo "Data for ". $info [ "count " ] ." items returned: <p>" ; 

for ($1=0; $i<$info ["count"] ; $i++) { 

echo "dn is: ". $inf o [ $1] [ "dn" ] ."<br>"; 

echo "first en entry is: ". $info[$i] ["en"] [0] ."<br>"; 

echo "first email entry is: ". $info[$i] ["mail"] [0] ."<p>"; 
} 

echo "Closing connection"; 
ldap_close ($ds) ; 

} else { 

echo "<h4>Unable to connect to LDAP server</h4>" ; 
} 
?> 



Using the PHP LDAP calls 



You will need to get and compile LDAP client libraries from either the University of IVIichigan ldap-3.3 package 
or the Netscape Directory SDK. You will also need to recompile PHP with LDAP support enabled before PHP's 
LDAP calls will work. 

Before you can use the LDAP calls you will need to know .. 



q The name or address of the directory server you will use 

q The "base dn" of the server (the part of the world directory that is held on this server, which could be 
"o=My Company,c=US") 

q Whether you need a password to access the server (many servers will provide read access for an 
"anonymous bind" but require a password for anything else) 

The typical sequence of LDAP calls you will make in an application will follow this pattern: 

ldap_connect() // establish connection to server 

I 
ldap_bind() // anonymous or authenticated "login" 

I 
do something like search or update the directory 
and display the results 

I 
ldap_close() // "logout" 

More Information 

Lots of information about LDAP can be found at 

q Netscape 

q University of Michigan 

q OpenLDAP Project 

q LDAP World 

The Netscape SDK contains a helpful Programmer's Guide in .html format. 
Table of Contents 

// ldap_add Add entries to LDAP directory 

// ldap_mod_add Add attribute values to current attributes 

// ldap_mod_del Delete attribute values from current attributes 

// ldap_mod_replace Replace attribute values with new ones 

// ldap_bind Bind to LDAP directory 

// ldap_close Close link to LDAP server 

// ldap_connect Connect to an LDAP server 

// ldap_count_entries Count the number of entries in a search 

// ldap_delete Delete an entry from a directory 

// ldap_dn2ufn Convert DN to User Friendly Naming format 

// ldap_explode_dn Splits DN into its component parts 

// ldap_first_attribute Return first attribute 

// ldap_first_entrv Return first result id 

// ldap_free_result Free result memory 

// Idap get attributes Get attributes from a search result entry 

// ldap_get_dn Get the DN of a result entry 

// ldap_get_entries Get all result entries 



// ldap_get_values Get all values from a result entry 

// ldap_get_values_len Get all binary values from a result entry 

// ldap_list Single-level search 

// ldap_modifv Modify an LDAP entry 

// ldap_next_attribute Get the next attribute in result 

// ldap_next_entrv Get next result entry 

// ldap_read Read an entry 

// ldap_search Search LDAP tree 

// ldap_unbind Unbind from LDAP directory 

// ldap_err2str Convert LDAP error number into string error message 

// ldap_errno Return the LDAP error number of the last LDAP command 

// ldap_error Return the LDAP error message of the last LDAP command 



Prev Home Next 

ibase_timefmt Ug ldap_add 



PHP Manual 

Prev Next 



XXX. MCAL functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



MCAL stands for Modular Calendar Access Library. 

Libmcal is a C library for accessing calendars. It's written to be very modular, with plugable 
drivers. MCAL is the calendar equivalent of the IMAP module for mailboxes. 

With meal support, a calendar stream can be opened much like the mailbox stream with the IMAP 
support. Calendars can be local file stores, remote ICAP servers, or other formats that are supported 
by the meal library. 

Calendar events can be pulled up, queried, and stored. There is also support for calendar triggers 
(alarms) and reoccuring events. 

With libmcal, central calendar servers can be accessed and used, removing the need for any specific 
database or local file programming. 

To get these functions to work, you have to compile PHP with — with-mcal. That requires the 
meal library to be installed. Grab the latest version from http://mcal.chek.com/ and compile and 
install it. 

The following constants are defined when using the MCAL module: MCAL_SUNDAY, 
MCAL_MONDAY, MCAL_TUESDAY, MCAL_WEDNESDAY, MCAL_THURSDAY, 
MCAL_FRIDAY, MCAL_SATURDAY, MCAL_JANUARY, MCAL_FEBRUARY, 
MCAL_MARCH, MCAL_APRIL, MCAL_MAY, MCAL_JUNE, MCAL_JULY, 
MCAL_AUGUGT, MCAL_SEPTEMBER, MCAL_OCTOBER, MCAL_NOVEMBER, and 
MCAL_DECEMBER. Most of the functions use an internal event structure that is unique for each 
stream. This alleviates the need to pass around large objects between functions. There are 
convenience functions for setting, initializing, and retrieving the event structure values. 

Table of Contents 

// mcal_open Opens up an MCAL connection 

// mcal_close Close an MCAL stream 

// mcal_fetch_event Fetches an event from the calendar stream 

// mcal_list_events Return a list of events between two given datetimes 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



// mca: 



store event Store an event into an MCAL calendar 



delete event Delete an event from an MCAL calendar 



snooze Turn off an alarm for an event 



_list_alarms Return a list of events that has an alarm triggered at the given datetime 



_event_init Initializes a streams global event structure 



_event_set_category Sets the category of the streams global event structure 



_event_set_title Sets the title of the streams global event structure 



_event_set_description Sets the description of the streams global event structure 



_event_set_start Sets the start date and time of the streams global event structure 



_event_set_end Sets the end date and time of the streams global event structure 



_event_set_alarm Sets the alarm of the streams global event structure 



_event_set_class Sets the class of the streams global event structure 



_is_leap_year Returns if the given year is a leap year or not 



_days_in_month Returns the number of days in the given month 



_date_valid Returns true if the given year, month, day is a valid date 



_time_valid Returns true if the given year, month, day is a valid time 



_day_of_week Returns the day of the week of the given date 



_day_of_year Returns the day of the year of the given date 



_date_compare Compares two dates 



next recurrence Returns the next recurrence of the event 



_event_set_recur_daily Sets the recurrence of the streams global event structure 



_event_set_recur_weekly Sets the recurrence of the streams global event structure 



_event_set_recur_monthly_mday Sets the recurrence of the streams global event structure 



_event_set_recur_monthly_wday Sets the recurrence of the streams global event structure 



_event_set_recur_yearly Sets the recurrence of the streams global event structure 



_fetch_current_stream_event Returns an object containing the current streams event 



structure 

Prev Home Next 

Tan Up mcal_open 



PHP Manual 

Prev Next 



XXXI. Microsoft SQL Server functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



Table of Contents 

// mssql_close close MS SQL Server connection 

// mssql_connect open MS SQL server connection 

// mssql_data_seek move internal row pointer 

// mssql_fetch_array fetch row as array 

// mssql_fetch_field get field information 

// mssql_fetch_obiect fetch row as object 

// mssql_fetch_row get row as enumerated array 

// mssql_field_seek set field offset 

// mssql_free_result free result memory 

// mssql_num_fields get number of fields in result 

// mssql_num_rows get number of rows in result 

// mssql_pconnect open persistent MS SQL connection 

// mssql_query send MS SQL query 

// mssql_result get result data 

// mssql_select_db select MS SQL database 



Prev Home Next 

mcal_fetch_current_stream_event Up mssql_close 



PHP Manual 

Prev Next 



XXXIII. mSQL functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 

Table of Contents 



XX 111 lllV ~ 

geto I 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



//msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



// msq 



send mSQL query 

affected rows returns number of affected rows 



_close close mSQL connection 



_connect open mSQL connection 



_create_db create mSQL database 



_createdb create mSQL database 



_data_seek move internal row pointer 



_dbname get current mSQL database name 



_drop_db drop (delete) mSQL database 



_dropdb drop (delete) mSQL database 



_error returns error message of last msql call 



_fetch_array fetch row as array 



_fetch_field get field information 



_fetch_obiect fetch row as object 



_fetch_row get row as enumerated array 



_fieldname get field name 



field seek set field offset 



_fieldtable get table name for field 



_fieldtype get field type 



_fieldflags get field flags 



_fieldlen get field length 



_free_result free result memory 



_freeresult free result memory 



// msql_list_fields list result fields 

// msql_listfields list result fields 

// msql_list_dbs list mSQL databases on server 

// msqMistdbs list mSQL databases on server 

// msql_list_tables list tables in an mSQL database 

// msql_listtables list tables in an mSQL database 

// msql_num_fields get number of fields in result 

// msql_num_rows get number of rows in result 

// msql_numfields get number of fields in result 

// msql_numrows get number of rows in result 

// msqLpconnect open persistent mSQL connection 

// msqLquery send mSQL query 

// msql_regcase make regular expression for case insensitive match 

// msql_result get result data 

// msql_select_db select mSQL database 

// msql_selectdb select mSQL database 

// msql_tablename get table name of field 

Prev Home Next 

usleep Up msql 



PHP Manual 

Prev Next 



XXXIV. MySQL functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions allow you to access MySQL database servers. 

More information about MySQL can be found at http://www.mysql.com/ . 
Table of Contents 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



// mysq 



_affected_rows Get number of affected rows in previous MySQL operation 



_change_user Change logged in user on active connection 



_close close MySQL connection 



_connect Open a connection to a MySQL Server 



_create_db Create a MySQL database 



_data_seek Move internal result pointer 



_db_querv Send an MySQL query to MySQL 



_drop_db Drop (delete) a MySQL database 



_errno Returns the number of the error message from previous MySQL operation 



_error Returns the text of the error message from previous MySQL operation 



_fetch_array Fetch a result row as an associative array 



_fetch_field Get column information from a result and return as an object 



_fetch_lengths Get the length of each output in a result 



_fetch_obiect Fetch a result row as an object 



_fetch_row Get a result row as an enumerated array 



_field_name Get the name of the specified field in a result 



_field_seek Set result pointer to a specified field offset 



_field_table Get name of the table the specified field is in 



_field_type Get the type of the specified field in a result 



_field_flags Get the flags associated with the specified field in a result 



_field_len Returns the length of the specified field 



// mvsql_free_result Free result memory 

// mysql_insert_id Get the id generated from the previous INSERT operation 

// mysql_Hst_fields List MySQL result fields 

// mvsql_list_dbs List databases available on on MySQL server 

// mysql_list_tables List tables in a MySQL database 

// mysql_num_fields Get number of fields in result 

// mvsql_num_rows Get number of rows in result 

// mysqLpconnect Open a persistent connection to a MySQL Server 

// mysqLquery Send an SQL query to MySQL 

// mysqLresult Get result data 

// mysql_select_db Select a MySQL database 

// mysql_tablename Get table name of field 

Prev Home Next 

msql_tablename Up mysql_affected_rows 



PHP Manual 

Prev Next 



XXXV. Network functions 

Table of Contents 

// checkdnsrr Check DNS records corresponding to a given Internet host name or IP address. 

// closelog close connection to system logger 

// debugger_off disable internal PHP debugger 

// debugger_on enable internal PHP debugger 

// fsockopen Open Internet or Unix domain socket connection. 

// gethostbyaddr Get the Internet host name corresponding to a given IP address. 

// gethostbyname Get the IP address corresponding to a given Internet host name. 

// gethostbynamel Get a list of IP addresses corresponding to a given Internet host name. 

// getmxrr Get MX records corresponding to a given Internet host name. 

// getprotobyname get protocol number associated with protocol name 

// getprotobynumber get protocol name associated with protocol number 

// getservbyname get port number associated with an Internet service and protocol 

// getservbyport get Internet service which corresponds to port and protocol 

// openlog open connection to system logger 

// pfsockopen Open persistent Internet or Unix domain socket connection. 

set_socket_blocking Set blocking/non-blocking mode on a socket 

// syslog generate a system log message 

Prev Home Next 

mysql_tablename Ug checkdnsrr 



PHP Manual 

Prev Next 



XXXVI. NIS functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



NIS (formerly called Yellow Pages) allows network management of important administrative files 
(e.g. the password file). For more information refer to the NIS manpage and Introduction to 
YP/NIS . There is also a book called Managing NFS and NIS by Hal Stern. 

To get these functions to work, you have to configure PHP with — with-yp. 

Table of Contents 

// vp_get_default_domain Fetches the machine's default NIS domain. 

// yp_order Returns the order number for a map. 

// yp_master Returns the machine name of the master NIS server for a map. 

// vp_match Returns the matched line. 

// vp_first Returns the first key- value pair from the named map. 

// vp_next Returns the next key-value pair in the named map. 

// vp_errno Returns the error code of the previous operation. 

// yp_err_string Returns the error string associated with the previous operation. 

Prev Home Next 

syslog Up yp_get_default_domain 



PHP Manual 

Prev Next 



XXXVIII. Oracle functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



Table of Contents 

// Ora_Bind bind a PHP variable to an Oracle parameter 

// Ora_Close close an Oracle cursor 

// Ora_ColumnName get name of Oracle result column 

// Ora_ColumnType get type of Oracle result column 

// Ora_Commit commit an Oracle transaction 

// Ora_CommitOff disable automatic commit 

// Ora_CommitOn enable automatic commit 

// Ora_Error get Oracle error message 

// Ora_ErrorCode get Oracle error code 

// Ora_Exec execute parsed statement on an Oracle cursor 

// Ora_Fetch fetch a row of data from a cursor 

// Ora_GetColumn get data from a fetched row 

// Ora_Logoff close an Oracle connection 

// Ora_Logon open an Oracle connection 

// Ora_Open open an Oracle cursor 

// Ora_Parse parse an SQL statement 

// Ora Rollback roll back transaction 



Prev Home Next 

odbc_setoption Up Ora_Bind 



PHP Manual 

Prev Next 



XXXIX. Oracle 8 functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions allow you to access OracleS and Oracle? databases. It uses the OracleS 
Call-Interface (0CI8). You will need the OracleS client libraries to use this extension. 

This extension is more flexible than the standard Oracle extension. It supports binding of global and 
local PHP variables to Oracle placeholders, has full LOB, FILE and ROWID support and allows 
you to use user-supplied define variables. 

Table of Contents 

// OCIDefineByName Use a PHP variable for the define-step during a SELECT 

// OCIBindByName Bind a PHP variable to an Oracle Placeholder 

// OCILogon Establishes a connection to Oracle 

// OCIPLogon Connect to an Oracle database and log on using a persistant connection. Returns a 
new session. 

// OCINLogon Connect to an Oracle database and log on using a new connection. Returns a new 

session. 

// OCILogOff Disconnects from Oracle 

// OCIExecute Execute a statement 

// OCICommit Commits outstanding transactions 

// OCIRollback Rolls back outstanding transactions 

// OCINewDescriptor Initialize a new empty descriptor LOB/FILE (LOB is default) 

// OCIRowCount Gets the number of affected rows 

// OCINumCols Return the number of result columns in a statement 

// OCIResult Returns coulumn value for fetched row 

// OCIFetch Fetches the next row into result-buffer 

// OCIFetchlnto Fetches the next row into result-array 

// OCIFetchStatement Fetch all rows of result data into an array. 

// OCIColumnlsNULL test whether a result column is NULL 



// OCIColumnSize return result column size 

// OCIServerVersion Return a string containing server version information. 

// OCIStatementType Return the type of an OCI statement. 

// OCINewCursor return a new cursor (Statement-Handle) - use this to bind ref-cursors! 

// OCIFreeStatement Free all resources associated with a statement. 

// OCIFreeCursor Free all resources associated with a cursor. 

// OCIColumnName Returns the name of a column. 

// OCIColumnType Returns the data type of a column. 

// OCIParse Parse a query and return a statement 

// OCIError Return the last error of stmtlconnlglobal. If no error happened returns false. 

// OCIInternalDebug Enables or disables internal debug output. By default it is disabled 

Prev Home Next 

Ora_Rollback Up OCIDefineByName 



PHP Manual 

Prev Next 



XL. PDF functions 




Ihese functioni 
HP Lite edition, 
ook at the functions manual-page to 
ie if possible workaround exists. 

You can use the PDF functions in PHP to create PDF files if you have the PDF library by Thomas Merz 
(available at http ://www . pdflib . com/pdflib/index . html ; you will also need the JPEG library and the TIFF library 
to compile this. These two libs also quite often make problems when configuring php. Follow the messages of 
configure to fix possible problems. If you use pdflib 2.01 check how the lib was installed. There should be file or 
link libpdf.so. Version 2.01 just creates a lib with the name libpdf2.01.so which cannot be found when linking the 
test programm in configure. You will have to create a symbolic link from libpdf.so to libpdf2.01.so.). Please 
consult the excellent documentation for pdflib shipped with the source distribution of pdflib. It provides a very 
good overview of what pdflib capable of doing. Most of the functions in pdflib and the PHP module have the 
same name. The parameters are also identical. You should also understand some of the concepts of PDF or 
Postscript to efficiently use this module. All lengths and coordinates are measured in Postscript points. There are 
generally 72 PostScript points to an inch, but this depends on the output resolution. 

There is another PHP module for pdf document creation based on FastlO's . ClibPDF. It has a slightly different 
API. Check the ClibPDF functions section for details. 

Currently all versions of pdflib are supported. It is recommended that you use the newest version since it has 
more features and fixes some problems which required a patch for the old version. Unfortunately, the changes of 
the pdflib API in 2.x compared to 0.6 have been so severe that even some PHP functions had to be altered. Here 
is a list of changes: 

q The Info structure does not exist anymore. Therefore the function pdf__get_info() is obsolete and the 
functions pdf_set_info_creator() , pdf_set_info_titIe() , pdf_set_info_author() , pdf_set_info_subject() 
and pdf_set_info_keywords() do not take the info structure as the first parameter but the pdf document. 
This also means that the pdf document must be opened before these functions can be called. 

q The way a new document is opened has changed. The function pdf_open() takes only one parameter which 
is the file handle of a file opened with fopenQ . 

There were some more changes with the release 2.01 of pdflib which should be covered by PHP. Some functions 
are not required anymore (e.g. pdf_put_image() ). You will get a warning so don't be shocked. 

The pdf module introduces two new types of variables (if pdflib 2.x is used it is only one new type). They are 
called pdf doc and pdf in fo {pdf info is not existent if pdflib 2.x is used, pdf doc is a pointer to a pdf 
document and almost all functions need it as its first parameter, pdf info contains meta data about the PDF 
document. It has to be set before pdf_open() is called. 

Note: The following is only true for pdflib 0.6. Read the pdflib manual for newer version 

In order to output text into a PDF document you will need to provide the afm file for each font. Afm files contain 
font metrics for a Postscript font. By default these afm files are searched for in a directory named Tonts' relative 
to the directory where the PHP script is located. (Again, this was true for pdflib 0.6, newer versions do not not 



neccessarily need the afm files.) 

Most of the functions are fairly easy to use. The most difficult part is probably to create a very simple pdf 
document at all. The following example should help to get started. It uses the PHP functions for pdflib 0.6. It 
creates the file test.pdf with one page. The page contains the text "Times-Roman" in an outlined 30pt font. The 
text is also underlined. 

Example 1. Creating a PDF document with pdflib 0.6 

<?php 

$fp = f open ("test .pdf ", "w"); 

$info = PDF_get_info ; 

pdf_set_inf o_author ( $inf o, "Uwe Steinmann" ) ; 

PDF_set_info_title ($info, "Test for PHP wrapper of PDFlib 0.6"); 

PDF_set_inf o_author ( $inf o, "Name of Author"); 

pdf_set_inf o_creator ( $inf o, "See Author"); 

pdf_set_inf o_sub ject ($info, "Testing") ; 

$pdf = PDF_open ( $fp, $info) ; 

PDF_begin_page ($pdf, 595, 842); 

PDF_add_outline ($pdf , "Page 1"); 

pdf_set_font ($pdf , "Times-Roman", 30, 4); 

pdf_set_text_rendering ( $pdf , 1) ; 

PDF_show_xy ($pdf , "Times Roman outlined", 50, 750); 

pdf_moveto ($pdf, 50, 740); 

pdf_lineto ($pdf, 330, 740); 

pdf_stroke ($pdf ) ; 

PDF_end_page ($pdf ) ; 

PDF_close ($pdf ) ; 

f close ( $fp) ; 

echo "<A HREF=getpdf .php3>f inished</A>"; 

?> 

The PHP script getpdf.php3 just outputs the pdf document. 

<?php 

$fp = f open ("test .pdf ", "r"); 

header ( "Content-type : application/pdf " ) ; 

fpassthru ($fp) ; 

f close ( $fp) ; 

?> 

Doing the same with pdflib 2.x looks like the following: 

Example 2. Creating a PDF document with pdflib 2.0 

<?php 

$fp = f open ("test .pdf ", "w"); 

$pdf = PDF_open ($fp) ; 

pdf_set_inf o_author ( $pdf , "Uwe Steinmann"); 

PDF_set_info_title ($pdf , "Test for PHP wrapper of PDFlib 2.0"); 

PDF_set_inf o_author ( $pdf , "Name of Author"); 

pdf_set_inf o_creator ( $pdf , "See Author"); 

pdf_set_inf o_sub ject ($pdf, "Testing") ; 

PDF_begin_page ($pdf, 595, 842); 

PDF_add_outline ($pdf , "Page 1"); 

pdf_set_font ($pdf , "Times-Roman", 30, 4); 

pdf_set_text_rendering ( $pdf , 1) ; 



PDF_show_xy ($pdf , "Times Roman outlined", 50, 750); 

pdf_moveto ($pdf , 50, 74 0); 

pdf_lineto ($pdf , 330, 740); 

pdf_stroke ($pdf ) ; 

PDF_end_page ($pdf ) ; 

PDF_close ($pdf ) ; 

f close ( $fp) ; 

echo "<A HREF=getpdf .php3>f inished</A>"; 

?> 

The PHP script getpdf.phpS is the same as above. 

The pdflib distribution contains a more complex example which creates a serious of pages with an analog clock. 
This example converted into PHP using pdflib 2.0 looks as the following (you can see the same example in the 
documentation for the clibpdf module) : 

Example 3. pdfclock example from pdflib 2.0 distribution 

<?php 

$pdf filename = "clock.pdf"; 

$radius = 200; 

$margin = 20; 

$pagecount = 40; 

$fp = f open ( $pdf filename, "w"); 

$pdf = pdf_open ( $fp) ; 

pdf_set_inf o_creator ( $pdf , "pdf_clock . php3 " ) ; 

pdf_set_inf o_author ( $pdf , "Uwe Steinmann"); 

pdf_set_inf o_title ( $pdf , "Analog Clock"); 

while ( $pagecount-- > 0) { 

pdf_begin_page ( $pdf , 2 * ($radius + $margin) , 2 * ($radius + $margin) ) ; 

pdf_set_transition ( $pdf , 4); /* wipe */ 
pdf_set_duration ( $pdf , 0.5); 

pdf_translate ( $pdf , $radius + $margin, $radius + $margin) ; 

pdf_save ($pdf ) ; 

pdf_setrgbcolor ($pdf, 0.0, 0.0, 1.0); 

/* minute strokes */ 

pdf_setlinewidth ( $pdf , 2.0); 

for ($alpha = 0; $alpha < 360; $alpha += 6) { 

pdf_rotate ( $pdf , 6.0); 

pdf_moveto ( $pdf , $radius, 0.0); 

pdf_lineto ( $pdf , $radius-$margin/3, 0.0); 

pdf_stroke ($pdf ) ; 
} 

pdf_restore ($pdf ) ; 
pdf_save ($pdf ) ; 

/* 5 minute strokes */ 

pdf_setlinewidth ( $pdf , 3.0); 

for ($alpha = 0; $alpha < 360; $alpha += 30) { 



pdf_rotate ($pdf, 30.0); 
pdf_moveto ( $pdf , $radius, 0.0); 
pdf_lineto ( $pdf , $radius-$margin, 0.0! 
pdf_stroke ($pdf ) ; 



$ltime = getdateO; 

/* draw hour hand */ 

pdf_save ($pdf ) ; 

pdf_rotate ($pdf , - ( ($ltime [ 'minutes ' ] /60 .0) +$ltime [ 'hours ' ] -3 . 0) *30 . 0) ; 

pdf_moveto ( $pdf , -$radius/10, -$radius/20) ; 

pdf_lineto ( $pdf , $radius/2, 0.0); 

pdf_lineto ( $pdf , -$radius/10, $radius/20); 

pdf_closepath ( $pdf ) ; 

pdf_fill ($pdf) ; 

pdf_restore ($pdf ) ; 

/* draw minute hand */ 

pdf_save ($pdf ) ; 

pdf_rotate ($pdf,- ( ($ltime [ 'seconds' ] /60.0) +$ltime [ 'minutes' ] -15.0) *6.0) ; 

pdf_moveto ( $pdf , -$radius/10, -$radius/20) ; 

pdf_lineto ( $pdf , $radius * 0.8, 0.0); 

pdf_lineto ( $pdf , -$radius/10, $radius/20); 

pdf_closepath ( $pdf ) ; 

pdf_fill ($pdf) ; 

pdf_restore ($pdf ) ; 

/* draw second hand */ 

pdf_setrgbcolor ($pdf, 1.0, 0.0, 0.0); 

pdf_setlinewidth ( $pdf , 2); 

pdf_save ($pdf ) ; 

pdf_rotate ($pdf, -( ($ltime [' seconds ' ] - 15.0) * 6.0)); 

pdf_moveto ( $pdf , -$radius/5, 0.0); 

pdf_lineto ( $pdf , $radius, 0.0); 

pdf_stroke ($pdf ) ; 

pdf_restore ($pdf ) ; 

/* draw little circle at center */ 
pdf_circle ( $pdf , 0, 0, $radius/30); 
pdf_fill ($pdf) ; 

pdf_restore ($pdf ) ; 

pdf_end_page ($pdf ) ; 



} 



$pdf = pdf_close ( $pdf ) ; 

f close ( $fp) ; 

echo "<A HREF=getpdf .php3?f ilename=" . $pdf filename . ">f inished</A>" ; 

?> 



The PHP script getpdf.php3 just outputs the pdf document. 



<?php 

$fp = f open ( $f ilename, "r"); 

header ( "Content-type : application/pdf " ) ; 

fpassthru ($fp) ; 

f close ( $fp) ; 

?> 

Table of Contents 

// PDF_get_info Returns a default info structure for a pdf document 
// PDF set info creator Fills the creator field of the info structure 



// PDF set info title Fills the title field of the info structure 



// PDF_set_info_subiect Fills the subject field of the info structure 



// PDF_set_info_kevwords Fills the keywords field of the info structure 



// PDF_set_info_author Fills the author field of the info structure 

// PDF open Opens a new pdf document 

// PDF_close Closes a pdf document 

// PDF_begin_page Starts new page 

// PDF_end_page Ends a page 

// PDF_show Output text at current position 

// PDF_show_xv Output text at given position 

// PDF_set_font Selects a font face and size 

// PDF_set_leading Sets distance between text lines 

// PDF_set_text_rendering Determines how text is rendered 

// PDF set horiz scaling Sets horizontal scaling of text 

// PDF_set_text_rise Sets the text rise 

// PDF_set_text_matrix Sets the text matrix 

// PDF_set_text_pos Sets text position 

// PDF_set_char_spacing Sets character spacing 

// PDF_set_word_spacing Sets spacing between words 

// PDF_continue_text Outputs text in next line 

// PDF_stringwidth Returns width of text using current font 

// PDF_save Saves the current environment 

// PDF_restore Restores formerly saved environment 

// PDF_translate Sets origin of coordinate system 

// PDF_scale Sets scaling 

// PDF_rotate Sets rotation 

//PDF setflat Sets flatness 

// PDF_setlineioin Sets linejoin parameter 

// PDF_setlinecap Sets linecap parameter 

// PDF_setmiterlimit Sets miter limit 

// PDF setlinewidth Sets line width 



// PDF_setdash Sets dash pattern 

//PDF moveto Sets current point 

// PDF_curveto Draws a curve 

// PDF_lineto Draws a line 

// PDF_circle Draws a circle 

// PDF_arc Draws an arc 

// PDF_rect Draws a rectangle 

// PDF_closepath Closes path 

// PDF_stroke Draws line along path 

// PDF_closepath_stroke Closes path and draws line along path 

//PDF fill Fills current path 

// PDF_fill_stroke Fills and strokes current path 

// PDF_closepath_fill_stroke Closes, fills and strokes current path 

// PDF_endpath Ends current path 

// PDF_clip Clips to current path 

// PDF_setgrav_fill Sets filling color to gray value 

// PDF_setgrav_stroke Sets drawing color to gray value 

// PDF_setgrav Sets drawing and filling color to gray value 

// PDF_setrgbcolor_fill Sets filling color to rgb color value 

// PDF_setrgbcolor_stroke Sets drawing color to rgb color value 

// PDF_setrgbcolor Sets drawing and filling color to rgb color value 

// PDF_add_outline Adds bookmark for current page 

// PDF_set_transition Sets transition between pages 

// PDF_set_duration Sets duration between pages 

// PDF_open_gif Opens a GIF image 

// PDF_open_memorv_image Opens an image created with PHP's image functions 

// PDF_open_ipeg Opens a JPEG image 

// PDF_close_image Closes an image 

// PDF_place_image Places an image on the page 

// PDF_put_image Stores an image in the PDF for later use 

// PDF_execute_image Places a stored image on the page 

// pdf_add_annotation Adds annotation 

Prev Home Next 

OCIInternalDebug Up PDF_get_info 



PHP Manual 

Prev Next 



XLI. Perl-compatible Regular 
Expression functions 



These functions are not suppc 

PHP Lite edition. 

Look at the functions manual-page to 

^^^ossibl^wo^araun^xists™ 




The syntax for patterns used in these functions closely resembles Perl. The expression should be 
enclosed in the delimiters, a forward slash (/), for example. Any character can be used for delimiter 
as long as it's not alphanumeric or backslash (\). If the delimiter character has to be used in the 
expression itself, it needs to be escaped by backslash. 

The ending delimiter may be followed by various modifiers that affect the matching. See Pattern 
Modifiers . 

Example 1. Examples of valid patterns 

q /<\Aw+>/ 

q l(\d{3})-\d+ISm 

q /^(?i)php[34]/ 
Example 2. Examples of invalid patterns 

q /href='(.*)' - missing ending delimiter 

q Aw+\s*\w+/J - unknown modifier 'J' 

q l-\d3-\d3-\d4l - missing starting delimiter 
Table of Contents 

// preg_match Perform a regular expression match 

// preg_match_all Perform a global regular expression match 

// preg_replace Perform a regular expression search and replace 

// preg_split Split string by a regular expression 

// preg_quote Quote regular expression characters 

// preg_grep Return array entries that match the pattern 

Pattern Modifiers describes possible modifiers in regex patterns 



Pattern Syntax describes PCRE regex syntax 



Prev Home Next 

pdf_add_annotation U^ preg_match 



PHP Manual 



Prev 



Next 



XLIV. PostgreSQL functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



Postgres, developed originally in the UC Berkeley Computer Science Department, pioneered many 
of the object-relational concepts now becoming available in some commercial databases. It 
provides SQL92/SQL3 language support, transaction integrity, and type extensibility. PostgreSQL 
is a public-domain, open source descendant of this original Berkeley code. 

PostgreSQL is available without cost. The current version is available at www.PostgreSQL.org . 

Since version 6.3 (03/02/1998) PostgreSQL use unix domain sockets, a table is given to this new 
possibilities. This socket will be found in /tmp/.s.PGSQL.5432. This option can be enabled 
with the '-i' flag to postmaster and it's meaning is: "listen on TCP/IP sockets as well as Unix 
domain socket". 

Table 1. Postmaster and PHP 



Postmaster 


PHP 


Status 


postmaster & 


pg_connect("", "", "", "", "dbname"); 


OK 


postmaster -i & 


pg_connect("", "", "", "", "dbname"); 


OK 


postmaster & 


pg_connect("localhost", "", "", "", "dbname"); 


Unable to connect to PostgreSQL 
server: connectDB() failed: Is the 
postmaster running and accepting 
TCP/IP (with -i) connection at 
'localhost' on port '5432'? in 
/path/to/file.php3 on line 20. 


postmaster -i & 


pg_connect("localhost", "", "", "", "dbname"); 


OK 



One can also establish a connection with the following command: $conn = 
pg_Connect("host=localhost port=5432 dbname=chris"); 

To use the large object (lo) interface, it is necessary to enclose it within a transaction block. A 
transaction block starts with a begin and if the transaction was valid ends with commit and end. If 
the transaction fails the transaction should be closed with abort and rollback. 



Example 1. Using Large Objects 

<?php 

$database = pg_Connect ("", "", "", "", "jacarta"); 

pg_exec ($database, "begin"); 

$oid = pg_locreate ($database); 

echo ( "$oid\n" ) ; 

$handle = pg_loopen ($database, $oid, "w"); 

echo ( "$handle\n" ) ; 

pg_lowrite ($handle, "gaga"); 

pg_loclose ($handle); 
pg_exec ($database, "commit") 
pg_exec ($database, "end") 
?> 

Table of Contents 

// pg_Close closes a PostgreSQL connection 

// pg_cmdTuples returns number of affected tuples 

// pg_Connect opens a connection 

// pg_DBname database name 

// pg_ErrorMessage error message 

// pg_Exec execute a query 

// pg_Fetch_Array fetch row as array 

// pg_Fetch_Object fetch row as object 

// pg_Fetch_Row get row as enumerated array 

// pg_FieldIsNull Test if a field is NULL 

// pg_FieldName Returns the name of a field 

// pg_FieldNum Returns the number of a column 

// pg_FieldPrtLen Returns the printed length 

// pg_FieldSize Returns the internal storage size of the named field 

// pg_FieldType Returns the type name for the corresponding field number 

// pg_FreeResult Frees up memory 

// pg_GetLastOid Returns the last object identifier 

// pg_Host Returns the host name 

// pg_loclose close a large object 

// pg_locreate create a large object 

// pg_loopen open a large object 

// pg_loread read a large object 

// pg_loreadall read a entire large object 

// pg_lounlink delete a large object 



// pg_lowrite write a large object 

// pg_NumFields Returns the number of fields 

// pg_NumRows Returns the number of rows 

// pg_Options Returns options 

// pg_pConnect make a persistent database connection 

// pg_Port Returns the port number 

// pg_Result Returns values from a result identifier 

// pg_ttv Returns the tty name 



Prev Home Next 

posix_getrlimit Ug pg_Close 



PHP Manual 

Prev Next 



XLVII. Regular expression functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



Regular expressions are used for complex string manipulation in PHP. The functions that support 
regular expressions are: 

q eregO 

q ereg_replace() 

q eregJQ 

q eregi_replace() 

q splitQ 

These functions all take a regular expression string as their first argument. PHP uses the POSIX 
extended regular expressions as defined by POSIX 1003.2. For a full description of POSIX regular 
expressions see the regex man pages included in the regex directory in the PHP distribution. It's in 
manpage format, so you'll want to do something along the lines of man 
/usr/local/src/regex/regex.7 in order to read it. 

Example 1. Regular expression examples 

ereg ( "abc" , $string) ; 

/* Returns true if "abc" 

is found anywhere in $string. */ 

ereg ("■^ abc", $string) ; 

/* Returns true if "abc" 

is found at the beginning of $string. */ 

ereg("abc$", $string) ; 

/* Returns true if "abc" 

is found at the end of $string. */ 

eregi (" (ozilla. [23] IMSIE.3) ", $HTTP_USER_AGENT) ; 
/* Returns true if client browser 
is Netscape 2, 3 or MSIE 3. */ 



eregC ( [ [ :alnum: ] ] +) ( [ [ : alnum: ] ] +) ( [ [ : alnum: ] ] +) " , 

$string, $regs) ; 
/* Places three space separated words 

into $regs[l], $regs[2] and $regs[3]. */ 

$string = ereg_replace ( " ^ " , "<BR>" , $string) ; 

/* Put a <BR> tag at the beginning of $string. */ 

$string = ereg_replace ( " $" , "<BR>" , $string) ; 
/* Put a <BR> tag at the end of $string. */ 

$string = ereg_replace ( " \n" , " " , $string) ; 
/* Get rid of any carriage return 
characters in $string. */ 

Table of Contents 

// ereg regular expression match 

// ereg_replace replace regular expression 

// eregi case insensitive regular expression match 

// eregi_replace replace regular expression case insensitive 

// split split string into array by regular expression 

// sql_regcase make regular expression for case insensitive match 

Prev Home Next 

recode_file Up ereg 



PHP Manual 

Prev Next 



XLIX. Session handling functions 




rhese functions are not supported in 
pHP Lite edition. 

^ook at the functions manual-page t( 
^e if possible workaround exists, 



Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to 
build more customized applications and increase the appeal of your web site. 

If you are familiar with the session management of PHPLIB, you will notice that some concepts are similar to 
PHP's session support. 

A visitor accessing your web site is assigned an unique id, the so-called session id. This is either stored in a cookie 
on the user side or is propagated in the URL. 

The session support allows you to register arbitrary numbers of variables to be preserved across requests. When a 
visitor accesses your site, PHP will check automatically (if session. auto_start is set to 1) or on your request 
(explicitly through session_start() or implicitly through session_register () ) whether a specific session id has been 
sent with the request. If this is the case, the prior saved environment is recreated. 

All registered variables are serialized after the request finishes. Registered variables which are undefined are 
marked as being not defined. On subsequent accesses, these are not defined by the session module unless the user 
defines them later. 

There are two methods to propagate a session id: 

q Cookies 

q URL parameter 

The session module supports both methods. Cookies are optimal, but since they are not reliable (clients are not 
bound to accept them), we cannot rely on them. The second method embeds the session id directly into URLs. 

PHP is capable of doing this transparently when compiled with --enable-trans-sid. If you enable this 
option, relative URIs will be changed to contain the session id automatically. Alternatively, you can use the 
constant SID which is defined, if the client did not send the appropiate cookie. S ID is either of the form 
session_name=session_id or is an empty string. 

The following example demonstrates how to register a variable, and how to link correctly to another page using 
SID. 



Example 1. Counting the number of hits of a single user 

<?php 

session_register ( "count " ) ; 

$count++; 

?> 

Hello visitor, you have seen this page <? echo $count; ?> times. <p> 

<? 

# the <?=SID?> is necessary to preserve the session id 

# in the case that the user has disabled cookies 
?> 

To continue, <A HREF="nextpage .php?<?=SID?>">click here</A> 

To implement database storage you need PHP code and a user level function session_set_save_handler(). You 
would have to extend the following functions to cover MySQL or another database. 

Example 2. Usage of session_set_save_handler() 

<?php 

function open ($save_path, $session_name) { 

echo "open ($save_path, $session_name) \n" ; 

return true; 
} 

function close () { 

echo "close\n"; 

return true; 
} 

function read ($key) { 

echo "write ($key, $val)\n"; 

return "fool 1:1;"; 
} 

function write ($key, $val) { 

echo "write ($key, $val)\n"; 

return true; 
} 

function destroy ($key) 

return true; 
} 

function gc ( $maxlif etime) { 

return true; 
} 

session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); 

session start ( ) ; 



$foo++; 
?> 

Will produce this results: 

$ . /php save_handler .php 

Content-Type: text /html 

Set-cookie: PHPSESSID=f 8b92 5af 0ecb52bdd2de97d95cdbe6b 

open (/tmp, PHPSESSID) 

read (f 08b92 5af 0ecb52bdd2de97d95cdbe6b) 

write (f08b925af0ecb52bdd2de97d95cdbe6b, foo|i:2;) 

close 

The <? = SID?> is not necessary, if --enable-trans-sid was used to compile PHP. 

The session management system supports a number of configuration options which you can place in your php.ini 
file. We will give a short overview. 

q session . save_handler defines the name of the handler which is used for storing and retrieving data 
associated with a session. Defaults to files. 

q session. save_path defines the argument which is passed to the save handler. If you choose the default 
files handler, this is the path where the files are created. Defaults to /tmp. 

q session, name specifies the name of the session which is used as cookie name. It should only contain 
alphanumeric characters. Defaults to PHPSESSID. 

q session. auto_start specifies whether the session module start a session automatically on request 
startup. Defaults to (disabled). 

q session. lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The 
value means "until the browser is closed." Defaults to 0. 

q session . serialize_handler defines the name of the handler which is used to serialize/deserialize 
data. Currently, a PHP internal format (name php) and WDDX is supported (name wddx). WDDX is only 
available, if PHP is compiled with WDDX support . Defaults to php. 

q session . gc_probability specifies the probability that the gc (garbage collection) routine is started 
on each request in percent. Defaults to 1 . 

q session . gc_maxlif et ime specifies the number of seconds after which data will be seen as 'garbage' 
and cleaned up. 

q session . extern_ref erer_check determines whether session ids referred to by external sites will 
be eliminated. If session ids are propagated using the URL method, users not knowing about the impact 
might publish session ids. This can lead to security problems which this check tries to defeat. Defaults to 0. 

q session. entropy_f lie gives a path to an external resource (file) which will be used as an additional 
entropy source in the session id creation process. Examples are /dev/random or /dev/urandom which 
are available on many Unix systems. 

q session. entropy_length specifies the number of bytes which will be read from the file specified 
above. Defaults to (disabled). 

q session . use_cookies specifies whether the module will use cookies to store the session id on the 
client side. Defaults to 1 (enabled). 



Note: Session handling was added in PHP 4.0. 
Table of Contents 

// session start Initialize session data 



// session_destrov Destroys all data registered to a session 
// session name Get and/or set the current session name 



// session module name Get and/or set the current session module 



// session_save_path Get and/or set the current session save path 
// session id Get and/or set the current session id 



// session register Register one or more variables with the current session 
// session_unregister Unregister a variable from the current session 
// session_is_registered Find out if a variable is registered in a session 
// session_decode Decodes session data from a string 
// session_encode Encodes the current session data as a string 



Prev 

shm remove var 



Home 



Next 
session start 



PHP Manual 

Prev Next 



L. SNMP functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



In order to use the SNMP functions on Unix you need to install the UCD SNMP package. On 
Windows these functions are only available on NT and not on Win95/98. 

Important: In order to use the UCD SNMP package, you need to define 

NO_ZEROLENGTH_COMMUNITY to 1 before compiling it. After configuring UCD SNMP, edit 
config.h and search for NO_ZEROLENGTH_COMMUNITY. Uncomment the #define line. It 
should look like this afterwards: 

#define NO_ZEROLENGTH_COMMUNITY 1 

If you see strange segmentation faults in combination with SNMP commands, you did not follow 
the above instructions. If you do not want to recompile UCD SNMP, you can compile PHP with the 
~enable-ucd-snmp-hack switch which will work around the misfeature. 

Table of Contents 

// snmpget Fetch an SNMP object 

// snmpset Set an SNMP object 

// snmpwalk Fetch all the SNMP objects from an agent 

// snmpwalkoid Query for a tree of information about a network entity 

// snmp_get_quick_print Fetch the current value of the UCD library's quick_print setting 

// snmp_set_quick_print Set the value of quick_print within the UCD SNMP library. 

Prev Home Next 

session_encode Ug snmpget 



PHP Manual 

Prev Next 



LI. Solid functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



The Solid functions are deprecated, you probably want to use the Unified ODBC functions instead. 

Table of Contents 

// solid_close close a Solid connection 

// solid_connect connect to a Solid data source 

// solid_exec execute a Solid query 

// solid_fetchrow fetch row of data from Solid query 

// solid_fieldname get name of column from Solid query 

// solid_fieldnum get index of column from Solid query 

// solid_freeresult free result memory from Solid query 

// solid_numfields get number of fields in Solid result 

// solid_numrows get number of rows in Solid result 

// solid_result get data from Solid results 

Prev Home Next 

snmp_set_quick_print Up solid_close 



PHP Manual 

Prev Next 



Lll. String functions 



These functions all manipulate strings in various ways. Some more specialized sections can be 
found in the regular expression and URL handling sections. 

Table of Contents 

// AddCSlashes Quote string with slashes in a C style 

AddSlashes Quote string with slashes 

// bin2hex Convert binary data into hexadecimal representation 

Chop r emove trailing whitespace 

Chr Return a specific character 

// chunk_split Split a string into smaller chunks 

// convert_cyr_string Convert from one Cyrillic character set to another 

crypt DES-encrypt a string 

echo Output one or more strings 

explode Split a string by string 

flush Flush the output buffer 

// get_html_translation_table Returns the translation table used by htmlspecialcharsQ and 
htmlentitiesQ 

// get_meta_tags Extracts all meta tag content attributes from a file and returns an array 

htmlentities Convert all applicable characters to HTML entities 

htmlspecialchars Convert special characters to HTML entities 

implode Join array elements with a string 

// join Join array elements with a string 

// Itrim Strip whitespace from the beginning of a string 

//md5 Calculate the md5 hash of a string 

// Metaphone Calculate the metaphone key of a string 

nl2br Converts newlines to HTML line breaks. 

Ord Return ASCII value of character 

parse_str Parses the string into variables 

print Output a string 

printf output a formatted string 

// quoted_printable_decode Convert a quoted-printable string to an 8 bit string 



// QuoteMeta quote meta characters 

rawurldecode Decode URL-encoded strings 

rawurlencode URL-encode according to RFC 1738 

// setlocale Set locale information 

// similar_text Calculate the similarity between two strings 

// soundex Calculate the soundex key of a string 

sprintf Return a formatted string 

strcasecmp B inary safe case-insensitive string comparison 

strchr Find the first occurrence of a character. 

strcmp Binary safe string comparison 

// strcspn Find length of initial segment not matching mask 

// strip_tags Strip HTML and PHP tags from a string 

// StripCSlashes un-quote string quoted with addcslashes 

StripSlashes Un-quote string quoted with addslashes 

// stristr Case-insensitive strstrQ 

strlen Get string length 

strpos Find position of first occurrence of a string 

// strrchr Find the last occurrence of a character in a string 

// str_repeat Repeat a string 

// strrev Reverse a string 

// strrpos Find position of last occurrence of a char in a string 

// strspn Find length of initial segment matching mask 

strstr Find first occurrence of a string. 

// strtok Tokenize string 

// strtolower Make a string lowercase 

// strtoupper Make a string uppercase 

str_replace Replace all occurrences of needle in haystack with str 

// strtr Translate certain characters 

substr Return part of a string 

// substr_replace Replace text within a portion of a string. 

trim S trip whitespace from the beginning and end of a string 

// ucfirst Make a string's first character uppercase 

// ucwords Uppercase the first character of each word in a string 

Prev Home Next 



solid_result Ug AddCSlashes 



PHP Manual 

Prev Next 



Llll. Sybase functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists. 



XX 111 lllV ~ 

geto I 



Table of Contents 

// sybase_affected_rows get number of affected rows in last query 

// sybase_close close Sybase connection 

// sybase_connect open Sybase server connection 

// sybase_data_seek move internal row pointer 

// sybase_fetch_array fetch row as array 

// sybase_fetch_field get field information 

// sybase_fetch_obiect fetch row as object 

// sybase_fetch_row get row as enumerated array 

// sybase_field_seek set field offset 

// sybase_free_result free result memory 

// sybase_num_fields get number of fields in result 

// sybase_num_rows get number of rows in result 

// sybase_pconnect open persistent Sybase connection 

// sybase_query send Sybase query 

// sybase_result get result data 

// sybase_select_db select Sybase database 



Prev Home Next 

ucwords Up sybase_affected_rows 



PHP Manual 

Prev Next 



LIV. URL functions 

Table of Contents 

// base64_decode decodes data encoded with MIME base64 
// base64_encode encodes data with MIME base64 
parse_url parse a URL and return its components 
urldecode decodes URL-encoded string 
urlencode URL-encodes string 

Prev Home Next 

sybase_select_db Up base64_decode 



PHP Manual 

Prev Next 



LVI. Vmailmgr functions 



■These functions are not supported in tlie" 
IpHP Lite edition. 
■Look at the functions manual-page 
■see if possible workaround exists, 



XX 111 lllV ~ 

geto I 



These functions require qmail and the vmailmgr package by Bruce Guenter. 

For all functions, the following two variables are defined as: string vdomain the domain name of 
your virtual domain (vdomain.com) string basepwd the password of the 'real' user that holds the 
virtual users 

Only up to 8 characters are recognized in passwords for virtual users 

Return status for all functions matches response in response.h 

Ook 

Ibad 

2 error 

3 error connecting 

Known problems: vm_deluser() does not delete the user directory as it should. vm_addalias() 
currently does not work correctly. 

<?php 

dl ( "php3_vmailmgr . so" ) ; //load the shared library 

$vdomain=" vdomain . com" ; 

$basepwd="password" ; 

?> 

Table of Contents 

// vm_adduser Add a new virtual user with a password 

// vm_addalias Add an alias to a virtual user 

// vm_passwd Changes a virtual users password 

// vm_delalias Removes an alias 

// vm_deluser Removes a virtual user 

Prev Home Next 



unset Up vm_adduser 



PHP Manual 

Prev Next 



LVII. WDDX functions 



These functions are not supported in the 
'HP Lite edition. 

.ook at the functions manual-page 
Bee if possible workaround exists. 



11 iiiu 

J 



These functions are intended for work with WDDX . 

Note that all the functions that serialize variables use the first element of an array to determine whether 
the array is to be serialized into an array or structure. If the first element has string key, then it is 
serialized into a structure, otherwise, into an array. 

Example 1. Serializing a single value 

<?php 

print wddx_serialize_value ( "PHP to WDDX packet example", "PHP packet"); 

?> 

This example will produce: 

<wddxPacket version= ' . 9 ' xheader comment= ' PHP packet ' /><data> 
<string>PHP to WDDX packet exainple</string></data></wddxPacket> 

Example 2. Using incremental packets 

<?php 

$pi = 3.1415926; 

$packet_id = wddx_packet_start ( "PHP" ) ; 

wddx_add_vars ($packet_id, "pi") ; 

/* Suppose $cities came from database */ 
$cities = array ("Austin", "Novate", "Seattle"); 
wddx_add_vars ($packet_id, "cities") ; 

$packet = wddx_packet_end ($packet_id) ; 

print $packet; 

?> 



This example will produce: 

<wddxPacket version= ' . 9 ' xheader comment= ' PHP ' /><data><struct> 
<var name= 'pi ' ><number>3 . 1415 92 6< /number ></var><var name= ' cities ' > 
<array length= ' 3 ' ><string>Austin</string><string>Novato</string> 
<string>Seattle</string></array></var></struct></data></wddxPacket> 



Table of Contents 

// wddx_serialize_value Serialize a single value into a WDDX packet 

// wddx_serialize_vars Serialize variables into a WDDX packet 

// wddx_packet_start Starts a new WDDX packet with structure inside it 

// wddx_packet_end Ends a WDDX packet with the specified ID 

// wddx_add_vars Ends a WDDX packet with the specified ID 

// wddx_de serialize Deserializes a WDDX packet 

Prev Home Next 

vm_deluser Up wddx_serialize_value 



PHP Manual 

Prev Next 



split 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

spHt ~ spHt string into array by regular expression 

Description 

array split (string pattern, string string, int [Hmit]); 

Returns an array of strings, each of which is a substring of string formed by spHtting it on 
boundaries formed by the regular expression pattern. If an error occurs, returns false. 

To get the first five fields from a line from /etc/passwd: 
Example 1. split() example 

$passwd_list = split ( ":", $passwd_line, 5 ); 

To parse a date which may be delimited with slashes, dots, or hyphens: 

Example 2. split() example 

$date = "04/30/1973"; // Delimiters may be slash, dot, or hyphen 
list ( $month, $day, $year ) = split ( '[/.-]', $date ); 
echo "Month: $month; Day: $day; Year: $year<br>\n" ; 

Note that pattern is case-sensitive. 

Note that if you don't require the power of regular expressions, it is faster to use explodeQ , which 
doesn't incur the overhead of the regular expression engine. 

Please note that patt ern is a regular expression. If you want to split on any of the characters 
which are considered special by regular expressions, you'll need to escape them first. If you think 
splitO (or any other regex function, for that matter) is doing something weird, please read the file 
regex . 7, included in the regex/ subdirectory of the PHP distribution. It's in manpage format, 
so you'll want to do something along the lines of man /usr/local/src/regex/regex.7 in order to read 
it. 

See also: explodeQ and implodeQ. 



Prev Home Next 

eregi_replace Up sql_regcase 



PHP Manual 

Prev Next 



wddx add vars 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

wddx_add_vars ~ Ends a WDDX packet with the specified ID 

Description 

wddx_add_var s(int packet_id, mixed name_var, mixed [...] ); 

wddx_add_vars() is used to seriaUze passed variables and add the result to the packet specified by 
the packet_id. The variables to be serialized are specified in exactly the same way as 
wddx_serialize_vars() . 

Prev Home Next 

wddx_packet_end Up wddx_deserialize 



PHP Manual 

Prev Next 



each 



This function is not supported in t 

PHP Lite edition. 

Possible workaround not yet published. 



ished. I 



each — Return the next key and value pair from an array 

Description 

array each(array array); 

Returns the current key and value pair from the array array and advances the array cursor. This 
pair is returned in a four-element array, with the keys 0, 1, key, and value. Elements and key 
contain the key name of the array element, and 1 and value contain the data. 

If the internal pointer for the array points past the end of the array contents, each() returns false. 

Example 1. each() examples 

$foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese" ) ; 
$bar = each ( $foo ); 

$bar now contains the following key/value pairs: 

q 0=>0 

q l=>'bob' 

q key => 

q value => 'bob' 

$foo = array ( "Robert" => "Bob", "Seppo" => "Sepi" ); 
$bar = each ( $foo ) ; 

$bar now contains the following key/value pairs: 
q 0=> 'Robert' 
q l=>'Bob' 
q key => 'Robert' 
q value => 'Bob' 

each() is typically used in conjunction with listQ to traverse an array; for instance. 



$HTTP_POST_VARS: 

Example 2. Traversing $HTTP_POST_VARS with eachQ 

echo "Values submitted via POST method: <br>" ; 

reset ($HTTP_POST_VARS) ; 

while (list($key, $val) = each ( $HTTP_POST_VARS) ) { 

echo "$key => $val<br>"; 
} 

After each() has executed, the array cursor will be left on the next element of the array, or on the 
last element if it hits the end of the array. 

See also key() , listQ , currentQ , resetQ , nextQ , and prevQ . 

Prev Home Next 

current Ug end 



PHP Manual 

Prev Next 



V. Appendixes 

Table of Contents 

A. Migrating from PHP/FI 2.0 to PHP 3.0 

B. PHP development 

C. The PHP Debugger 



Prev Home Next 

utf8_encode Migrating from PHP/FI 2.0 to 

PHP 3.0 



PHP Manual 

Prev Next 



posix_kill 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_kill — Send a signal to a process 

Description 

bool posix_kill(intpid, int sig); 

Send the signal sig to the process with the process identifier pid. Returns FALSE, if unable to 
send the signal, TRUE otherwise. 

See also the kill(2) manual page of your POSIX system, which contains additional information 
about negative process identifiers, the special pid 0, the special pid -1, and the signal number 0. 

Prev Home Next 

POSIX functions Up posix_getpid 



PHP Manual 

Prev Next 



posix_getpid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getpid ~ Return the current process identifier 

Description 

int posix_getpid(void ); 

Return the process identifier of the current process. 



Prev Home Next 

posix_kill Up posix_getppid 



PHP Manual 

Prev Next 



posix_getppid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getppid ~ Return the parent process identifier 

Description 

int posix_getppid(void ); 

Return the process identifier of the parent process of the current process. 

Prev Home Next 

posix_getpid Up posix_getuid 



PHP Manual 

Prev Next 



posix_getuid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getuid ~ Return the real user ID of the current process 

Description 

int posix_getuid(void ); 

Return the numeric real user ID of the current process. See also posix_getpwuid() for information 
on how to convert this into a useable usemame. 

Prev Home Next 

posix_getppid Up posix_geteuid 



PHP Manual 

Prev Next 



posix_geteuid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_geteuid ~ Return the effective user ID of the current process 

Description 

int posix_geteuid(void ); 

Return the numeric effective user ID of the current process. See also posix_getpwuid() for 
information on how to convert this into a useable usemame. 

Prev Home Next 

posix_getuid Up posix_getgid 



PHP Manual 

Prev Next 



posix_getgid 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



posix_getgid ~ Return the real group ID of the current process 

Description 

int posix_getgid(void ); 

Return the numeric real group ID of the current process. See also posix_getgrgid() for information 
on how to convert this into a useable group name. 

Prev Home Next 

posix_geteuid Up posix_getegid 



PHP Manual 

Prev Next 



posix_getegid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getegid ~ Return the effective group ID of the current process 

Description 

int posix_getegid(void ); 

Return the numeric effective group ID of the current process. See also posix_getgrgid() for 
information on how to convert this into a useable group name. 

Prev Home Next 

posix_getgid Up posix_setuid 



PHP Manual 

Prev Next 



posix_setuid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_setuid ~ Set the effective UID of the current process 

Description 

bool posix_setuid(int uid); 

Set the real user ID of the current process. This is a privileged function and you need appropriate 
privileges (usually root) on your system to be able to perform this function. 

Returns TRUE on success, FALSE otherwise. See also posix_setgid() . 

Prev Home Next 

posix_getegid Ug posix_setgid 



PHP Manual 

Prev Next 



posix_setgid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_setgid ~ Set the effective GID of the current process 

Description 

bool posix_setgid(int gid); 

Set the real group ID of the current process. This is a privileged function and you need appropriate 
privileges (usually root) on your system to be able to perform this function. The appropriate order 
of function calls is posix_setgid() first, posix_setuid() last. 

Returns TRUE on success, FALSE otherwise. 

Prev Home Next 

posix_setuid Up posix_getgroups 



PHP Manual 

Prev Next 



posix_getgroups 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getgroups ~ Return the group set of the current process 

Description 

array posix_getgroups(void ); 

Returns an array of integers containing the numeric group ids of the group set of the current 
process. See also posix_getgrgid() for information on how to convert this into useable group 
names. 

Prev Home Next 

posix_setgid Up posix_getlogin 



PHP Manual 

Prev Next 



posix_getlogin 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getlogin ~ Return login name 

Description 

string posix_getlogin(void ); 

Returns the login name of the user owning the current process. See posix_getpwnam() for 
information how to get more information about this user. 

Prev Home Next 

posix_getgroups Up posix_getpgrp 



PHP Manual 

Prev Next 



posix_getpgrp 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getpgrp ~ Return the current process group identifier 

Description 

int posix_getpgrp(void ); 

Return the process group identifier of the current process. See POSIX.l and the getpgrp(2) manual 
page on your POSIX system for more information on process groups. 

Prev Home Next 

posix_getlogin Up posix_setsid 



PHP Manual 

Prev Next 



posix_setsid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_setsid ~ Make the current process a session leader 

Description 

int posix_setsid(void ); 

Make the current process a session leader. See POSIX.l and the setsid(2) manual page on your 
POSIX system for more informations on process groups and job control. Returns the session id. 

Prev Home Next 

posix_getpgrp Up posix_setpgid 



PHP Manual 

Prev Next 



posix_setpgid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_setpgid ~ set process group id for job control 

Description 

int posix_setpgid(intpid, intpgid); 

Let the process pi d join the process group pgid. See POSIX.l and the setsid(2) manual page on 
your POSIX system for more informations on process groups and job control. Returns TRUE on 
success, FALSE otherwise. 

Prev Home Next 

posix_setsid Up posix_getpgid 



PHP Manual 

Prev Next 



posix_getpgid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getpgid ~ Get process group id for job control 

Description 

int posix_getpgid(int pid); 

Returns the process group identifier of the process pid. 

This is not a POSIX function, but is common on BSD and System V systems. If your system does 
not support this function at system level, this PHP function will always return FALSE. 

Prev Home Next 

posix_setpgid U^ posix_setsid 



PHP Manual 

Prev Next 



posix_setsid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_setsid ~ Get the current sid of the process 

Description 

int posix_getsid(int pid); 

Return the sid of the process pid. If pid is 0, the sid of the current process is returned. 

This is not a POSIX function, but is common on System V systems. If your system does not support 
this function at system level, this PHP function will always return FALSE. 

Prev Home Next 

posix_getpgid U^ posix_uname 



PHP Manual 

Prev Next 



posix_uname 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



posix_uname ~ Get system name 

Description 

array posix_uname(void ); 

Returns a hash of strings with information about the system. The indices of the hash are 

q sysname - operating system name (e.g. Linux) 

q nodename - system name (e.g. vahant) 

q release - operating system release (e.g. 2.2.10) 

q version - operating system version (e.g. #4 Tue Jul 20 17:01:36 MEST 1999) 

q machine - system architecture (e.g. i586) 

Posix requires that you must not make any assumptions about the format of the values, e.g. you 
cannot rely on three digit version numbers or anything else returned by this function. 

Prev Home Next 

posix_setsid U^ posix_times 



PHP Manual 

Prev Next 



posix_times 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



posix_times ~ Get process times 

Description 

array posix_times(void ); 

Returns a hash of strings with information about the current process CPU usage. The indices of the 
hash are 

q ticks - the number of clock ticks that have elapsed since reboot. 

q utime - user time used by the current process. 

q stime - system time used by the current process. 

q cutime - user time used by current process and children. 

q cstime - system time used by current process and children. 

Prev Home Next 

posix_uname Up posix_ctermid 



PHP Manual 

Prev Next 



posix_ctermid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_ctermid ~ Get path name of controlHng terminal 

Description 



string posix_ctermid(void ); 
Needs to be written. 



Prev Home Next 

posix_times Up posix_ttyname 



PHP Manual 

Prev Next 



posix_ttyname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_ttyname ~ Determine terminal device name 

Description 



string posix_ttyname(int fd); 
Needs to be written. 



Prev Home Next 

posix_ctermid Up posix_isatty 



PHP Manual 

Prev Next 



posixjsatty 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



posix_isatty ~ Determine if a file descriptor is an interactive terminal 

Description 



bool posix_isatty(int fd); 
Needs to be written. 



Prev Home Next 

posix_ttyname Up posix_getcwd 



PHP Manual 

Prev Next 



posix_getcwd 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getcwd ~ Pathname of current directory 

Description 

string posix_getcwd(void ); 
Needs to be written ASAP. 



Prev Home Next 

posix_isatty Up posix_mk:fifo 



PHP Manual 

Prev Next 



posix_mkfifo 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_mk:fifo ~ Create a fifo special file (a named pipe) 

Description 

bool posix_getcwd(string pathname, int mode); 
Needs to be written ASAP.. 



Prev Home Next 

posix_getcwd Up posix_getgrnam 



PHP Manual 

Prev Next 



posix_getgrnam 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getgrnam ~ Return info about a group by name 

Description 



array posix_getgrnam(string name); 
Needs to be written. 



Prev Home Next 

posix_mkfifo Up posix_getgrgid 



PHP Manual 

Prev Next 



posix_getgrgid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getgrgid ~ Return info about a group by group id 

Description 



array posix_getgrgid(int gid); 
Needs to be written. 



Prev Home Next 

posix_getgrnam Up posix_getpwnam 



PHP Manual 

Prev Next 



posix_getpwnam 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getpwnam ~ Return info about a user by name 

Description 



array posix_getpwnam(string name); 
Needs to be written ASAP. 



Prev Home Next 

posix_getgrgid Up posix_getpwuid 



PHP Manual 

Prev Next 



posix_getpwuid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getpwuid ~ Return info about a user by user id 

Description 



array posix_getpwuid(int uid); 
Needs to be written ASAP. 



Prev Home Next 

posix_getpwnam Up posix_getrHmit 



PHP Manual 

Prev Next 



posix_getrlimit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

posix_getrHmit ~ Return info about system ressource Hmits 

Description 

array posix_getrlimit(void ); 
Needs to be written ASAP. 

Prev Home Next 

posix_getpwuid Up PostgreSQL functions 



PHP Manual 

Prev Next 



Pattern Modifiers 

Pattern Modifiers ~ describes possible modifiers in regex patterns 

Description 

The current possible PCRE modifiers are listed below. The names in parentheses refer to internal 
PCRE names for these modifiers. 

/ (PCRE_CASELESS) 

If this modifier is set, letters in the pattern match both upper and lower case 
letters. 

m (PCRE_MULTILINE) 

By default, PCRE treats the subject string as consisting of a single "line" of 
characters (even if it actually contains several newlines). The "start of line" 
metacharacter (^) matches only at the start of the string, while the "end of line" 
metacharacter ($) matches only at the end of the string, or before a terminating 
newline (unless E modifier is set). This is the same as Perl. 

When this modifier is set, the "start of line" and "end of line" constructs match 
immediately following or immediately before any newline in the subject string, 
respectively, as well as at the very start and end. This is equivalent to Perl's /m 
modifier. If there are no "\n" characters in a subject string, or no occurrences of 
^ or $ in a pattern, setting this modifier has no effect. 

s (PCRE_DOTALL) 

If this modifier is set, a dot metacharater in the pattern matches all characters, 
including newlines. Without it, newlines are excluded. This modifier is 
equivalent to Perl's /s modifier. A negative class such as [^a] always matches a 
newline character, independent of the setting of this modifier. 

X (PCRE_EXTENDED) 

If this modifier is set, whitespace data characters in the pattern are totally 
ignored except when escaped or inside a character class, and characters between 
an unescaped # outside a character class and the next newline character, 
inclusive, are also ignored. This is equivalent to Perl's /x modifier, and makes it 
possible to include comments inside complicated patterns. Note, however, that 
this applies only to data characters. Whitespace characters may never appear 
within special character sequences in a pattern, for example within the sequence 
(?( which introduces a conditional subpattern. 



If this modifier is set, preg_replace() does normal substitution of W references 
in the replacement string, evaluates it as PHP code, and uses the result for 
replacing the search string. 

Only preg_replace() uses this modifier; it is ignored by other PCRE functions. 

Note: This modifier was added in PHP 4.0. 
A (PCRE_ANCHORED) 

If this modifier is set, the pattern is forced to be "anchored", that is, it is 
constrained to match only at the start of the string which is being searched (the 
"subject string"). This effect can also be achieved by appropriate constructs in 
the pattern itself, which is the only way to do it in Perl. 

E (PCRE_DOLLAR_ENDONLY) 

If this modifier is set, a dollar metacharacter in the pattern matches only at the 
end of the subject string. Without this modifier, a dollar also matches 
immediately before the final character if it is a newline (but not before any other 
newlines). This modifier is ignored if m modifier is set. There is no equivalent to 
this modifier in Perl. 

S 

When a pattern is going to be used several times, it is worth spending more time 
analyzing it in order to speed up the time taken for matching. If this modifier is 
set, then this extra analysis is performed. At present, studying a pattern is useful 
only for non-anchored patterns that do not have a single fixed starting character. 

U (PCRE_UNGREEDY) 

This modifier inverts the "greediness" of the quantifiers so that they are not 
greedy by default, but become greedy if followed by "?". It is not compatible 
with Perl. It can also be set by a (?U) modifier setting within the pattern. 

X (PCRE_EXTRA) 

This modifier turns on additional functionality of PCRE that is incompatible 
with Perl. Any backslash in a pattern that is followed by a letter that has no 
special meaning causes an error, thus reserving these combinations for future 
expansion. By default, as in Perl, a backslash followed by a letter with no 
special meaning is treated as a literal. There are at present no other features 
controlled by this modifier. 

Prev Home Next 

preg_grep Up Pattern Syntax 



PHP Manual 

Prev Appendix B. PHP development Next 



Reporting Errors 



To report errors from an internal function, you should call the php3_error() function. This takes at 
least two parameters ~ the first is the level of the error, the second is the format string for the error 
message (as in a standard printfQ call), and any following arguments are the parameters for the 
format string. The error levels are: 

E_NOTICE 

Notices are not printed by default, and indicate that the script encountered something that could 
indicate an error, but could also happen in the normal course of running a script. For example, 
trying to access the value of a variable which has not been set, or calling statQ on a file that doesn't 
exist. 

E_WARNING 

Warnings are printed by default, but do not interrupt script execution. These indicate a problem that 
should have been trapped by the script before the call was made. For example, calling eregQ with 
an invalid regular expression. 

E_ERROR 

Errors are also printed by default, and execution of the script is halted after the function returns. 
These indicate errors that can not be recovered from, such as a memory allocation problem. 

E_PARSE 

Parse errors should only be generated by the parser. The code is listed here only for the sake of 
completeness. 

E_CORE_ERROR 

This is like an E_ERROR, except it is generated by the core of PHP. Functions should not generate 
this type of error. 



E_CORE_WARNING 

This is like an E_WARNING, except it is generated by the core of PHP. Functions should not 
generate this type of error. 

Prev Home Next 

Calling User Functions Ug The PHP Debugger 



PHP Manual 

Prev Next 



date 



date ~ format a local time/date 

Description 

string date (string format, int [timestamp] ); 

Returns a string formatted according to the given format string using the given timestamp or the 
current local time if no timestamp is given. 

The following characters are recognized in the format string: 

• a - "am" or "pm" 

• A - "AM" or "PM" 

• d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" 

• D - day of the week, textual, 3 letters; i.e. "Fri" 

• F - month, textual, long; i.e. "January" 

• h - hour, 12-hour format; i.e. "01" to "12" 

• H - hour, 24-hour format; i.e. "00" to "23" 

• g - hour, 12-hour format without leading zeros; i.e. "1" to "12" 

• G - hour, 24-hour format without leading zeros; i.e. "0" to "23" 

• i - minutes; i.e. "00" to "59" 

• j - day of the month without leading zeros; i.e. "1" to "31" 

• 1 (lowercase 'L') - day of the week, textual, long; i.e. "Friday" 

• L - boolean for whether it is a leap year; i.e. "0" or "1" 

• m- month; i.e. "01" to "12" 

• n - month without leading zeros; i.e. "1" to "12" 



q M - month, textual, 3 letters; i.e. "Jan" 

q s - seconds; i.e. "00" to "59" 

q S - English ordinal suffix, textual, 2 characters; i.e. "th", "nd" 

q t - number of days in the given month; i.e. "28" to "31" 

q U - seconds since the epoch 

q w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 

q Y-year, 4 digits; i.e. "1999" 

q y - year, 2 digits; i.e. "99" 

q z - day of the year; i.e. "0" to "365" 

q Z - timezone offset in seconds (i.e. "-43200" to "43200") 

Unrecognized characters in the format string will be printed as-is. The "Z" format will always return 
"0" when using gmdate()(). 

Example 1. date() example 

print (dateC'l dS of F Y h:i:s A" ) ) ; 

print ("July 1, 2000 is on a " . date("l", mktime (0, 0, 0, 7 , 1, 2000) ) ) ; 

It is possible to use date() and mktimeQ together to find dates in the future or the past. 

Example 2. date() and mktimeQ example 

$tomorrow = mktime (0, 0, 0, date ( "m" ) , date ( "d" ) +1, date ( "Y" )) ; 
$lastmonth = mktime (0, 0, 0, date ( "m" ) -1, date ( "d" ) , date("Y")); 
$nextYear = mktime (0, 0, 0, date ( "m" ) , date("d"), date ( "Y" ) +1) ; 

To format dates in other languages, you should use the setlocaleQ and strftimeQ functions. 
See also gmdateQ and mktimeQ . 

Prev Home Next 

checkdate Up getdate 



PHP Manual 

Prev Next 



usort 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



usort ~ Sort an array by values using a user-defined comparison function 

Description 

void usort(array array, function cmp_function); 

This function will sort an array by its values using a user-supplied comparison function. If the array 
you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. 

The comparison function must return an integer less than, equal to, or greater than zero if the first 
argument is considered to be respectively less than, equal to, or greater than the second. If two 
members compare as equal, their order in the sorted array is undefined. 

Example 1. usort() example 

function cmp($a,$b) { 

if ($a == $b) return 0; 
return ($a > $b) ? -1 : 1; 

} 

$a = array (3, 2, 5, 6, 1 ) ; 

usort ( $a, cmp) ; 

while (list ($key, $value) = each($a)) { 

echo "$key: $value\n"; 
} 
This example would display: 0: 61:52:33:24:1 

Note: Obviously in this trivial case the rsortQ function would be more appropriate. 



Warning 



The underlying quicksort function in some C libraries (such as on Solaris systems) may cause 
PHP to crash if the comparison function does not return consistent values. 



See also: arsortQ , asortQ , ksortQ , rsortQ and sortQ . 

Prev Home Next 



uksort Up Aspell functions 



PHP Manual 

Prev Next 



array_walk 



rhis function is not supported in the 

'HP Lite edition. 

'ossible workaround not yet published 



edj 



array _walk — Apply a user function to every member of an array. 

Description 

int array_walk(array arr, string func, mixed userdata); 

Applies the function named by func to each element of arr. Tunc will be passed array value as the first 
parameter and array key as the second parameter. If userdata is supplied, it will be passed as the third 
parameter to the user function. If run c requires more than two or three arguments, depending on 
userdata, a warning will be generated each time array _walk() calls func. These warnings may be 
suppressed by prepending the '@' sign to the array _walk() call, or by using error_reporting() . 

Note: If Tunc needs to be working with the actual values of the array, specify that the first 
parameter of func should be passed by reference. Then any changes made to those elements 
will be made in the array itself. 

Note: Passing the key and userdata to func was added in 4.0. 
Example 1. array _walk() example 

$ fruits = array ( "d"=>" lemon " , " a"=>" orange " , "b "=> "banana " , " c"=>" apple " ) ; 

function test_alter ( &$iteml, $key, $prefix ) { 

$iteml = "$prefix: $iteml"; 
} 

function test_print ( $item2, $key ) { 

echo "$key. $itein2<br>\n" ; 
} 

array_walk ( $fruits, 'test_print' ); 
array_walk ( $fruits, ' test_alter ' , 'fruit' ); 
array_walk ( $fruits, 'test_print' ); 

See also eachQ and listQ . 

Prev Home Next 

array_values Up arsort 



PHP Manual 

Prev Next 



list 

list ~ Assign variables as if they were an array 

Description 

void list(...); 

Like arrayO , this is not really a function, but a language construct. list() is used to assign a list of 
variables in one operation. 
Example 1. list() example 

<table> 
<tr> 
<th>Employee name</th> 
<th>Salary</th> 
</tr> 
<?php 

$result = mysql ( $conn, "SELECT id, name, salary FROM employees"); 
while (list($id, $name, $salary) = mysql_f etch_row ( $result ) ) { 
print (" <tr>\n" . 

" <td><a href=\"info.php3?id=$id\">$name</a></td>\n" . 

" <td>$salary</td>\n" . 

" </tr>\n") ; 
} 

?></table> 

See also: eachQ , arrayQ . 

Prev Home Next 

ksort Ug next 



PHP Manual 

Prev Chapter 18. Handling file uploads Next 

Uploading multiple files 

It is possible to upload multiple files simultaneously and have the information organized automatically in arrays 
for you. To do so, you need to use the same array submission syntax in the HTML form as you do with multiple 
selects and checkboxes: 

Note: Support for multiple file uploads was added in version 3.0.10. 
Example 18-2. Uploading multiple forms 

<form action=" file-upload. html" method="post " enctype="multipart /f orm-data"> 

Send these files :<br> 

<input name="userf lie [ ] " type=" f ile"><br> 

<input name="userf lie [ ] " type=" f ile"><br> 

<input type=" submit " value="Send files"> 
</f orm> 

When the above form is submitted, the arrays $userfile, $userf ile_name, and $userf ile_size will 
be formed in the global scope (as well as in $HTTP_POST_VARS). Each of these will be a numerically indexed 
array of the appropriate values for the submitted files. 

For instance, assume that the filenames /home/test /review, html and /home/test /xwp . out are 
submitted. In this case, $userf ile_name [ ] would contain the value review . html, and 
$userf ile_name [ 1 ] would contain the value xwp . out. Similarly, $userf ile_size [ ] would contain 
review . html's filesize, and so forth. 

Prev Home Next 

Common Pitfalls Up PUT method support 



PHP Manual 

Prev Next 



Chapter 18. Handling file uploads 

Table of Contents 

POST method uploads 
Common Pitfalls 
Uploading multiple files 
PUT method support 



POST method uploads 



PHP is capable of receiving file uploads from any RFC- 1867 compliant browser (which includes 
Netscape Navigator 3 or later, Microsoft Internet Explorer 3 with a patch from Microsoft, or later 
without a patch). This feature lets people upload both text and binary files. With PHP's 
authentication and file manipulation functions, you have full control over who is allowed to upload 
and what is to be done with the file once it has been uploaded. 

Note that PHP also supports PUT-method file uploads as used by Netscape Composer and W3C's 
Amaya clients. See the PUT Method Support for more details. 

A file upload screen can be built by creating a special form which looks something like this: 

Example 18-1. File Upload Form 

<FORM ENCTYPE="multipart/form-data" ACTION="_URL_" METHOD=POST> 

<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value=" 1000"> 

Send this file: <INPUT NAME="userf ile" TYPE="file"> 

<INPUT TYPE=" submit" VALUE="Send File"> 

</FORM> 

The _URL_ should point to a PHP file. The MAX_FILE_SIZE hidden field must precede the file 
input field and its value is the maximum filesize accepted. The value is in bytes. In this destination 
file, the following variables will be defined upon a successful upload: 

q $userfile - The temporary filename in which the uploaded file was stored on the server 
machine. 

q $userfile_name - The original name of the file on the sender's system. 

q $userfile_size - The size of the uploaded file in bytes. 

q $userfile_type - The mime type of the file if the browser provided this information. An 
example would be "image/gif". 

Note that the "$userfile" part of the above variables is whatever the name of the INPUT field of 



TYPE=file is in the upload form. In the above upload form example, we chose to call it "userfile". 

Files will by default be stored in the server's default temporary directory. This can be changed by 
setting the environment variable TMPDIR in the environment in which PHP runs. Setting it using 
putenvQ from within a PHP script will not work. 

The PHP script which receives the uploaded file should implement whatever logic is necessary for 
determining what should be done with the uploaded file. You can for example use the $file_size 
variable to throw away any files that are either too small or too big. You could use the $file_type 
variable to throw away any files that didn't match a certain type criteria. Whatever the logic, you 
should either delete the file from the temporary directory or move it elsewhere. 

The file will be deleted from the temporary directory at the end of the request if it has not been 
moved away or renamed. 

Prev Home Next 

Cookies Up Common Pitfalls 



PHP Manual 

Prev Next 



set_socket_blocking 

set_socket_blocking — Set blocking/non-blocking mode on a socket 

Description 

int set_socket_blocking(int socket descriptor, int mode); 

If mode is false, the given socket descriptor will be switched to non-blocking mode, and if true, it 
will be switched to blocking mode. This affects calls like fgetsQ that read from the socket. In 
non-blocking mode an fgets() call will always return right away while in blocking mode it will wait 
for data to become available on the socket. 

Prev Home Next 

pfsockopen Up syslog 



PHP Manual 

Prev Next 



Chapter 14. Error handling 

There are 4 types of errors and warnings in PHP. They are: 

q 1 - Normal Function Errors 

q 2 - Normal Warnings 

q 4 - Parser Errors 

q 8 - Notices (warnings you can ignore but which may imply a bug in your code) 

The above 4 numbers are added up to define an error reporting level. The default error reporting 
level is 7 which is 1 + 2 + 4, or everything except notices. This level can be changed in the php3.ini 
file with the error_reporting directive. It can also be set in your Apache httpd.conf file with the 
php3_error_reporting directive or lastly it may be set at runtime within a script using the 
error_reporting() function. 

All PHP expressions can also be called with the " @ " prefix, which turns off error reporting for that 
particular expression. If an error occurred during such an expression and the track_errors feature is 
enabled, you can find the error message in the global variable $php_errormsg. 

Prev Home Next 

Features Up Creating GIF images 



PHP Manual 

Prev Next 



Chapter 15. Creating GIF images 

PHP is not limited to creating just HTML output. It can also be used to create GIF image files, or 
even more convenient GIF image streams. You will need to compile PHP with the GD library of 
image functions for this to work. 

Example 15-1. GIF creation with PHP 

<?php 

Header ( "Content-type : image/gif " ) ; 

$string=implode ( $argv, " "); 

$im = imagecreatef romgif ( "images/buttonl . gif " ) ; 

$orange = ImageColorAllocate ($im, 220, 210, 60); 

$px = (imagesx ($im) -7 . 5*strlen ( $string) ) /2; 

ImageString ($im, 3, $px, 9, $string, $orange) ; 

ImageGif ($im) ; 

ImageDestroy ($im) ; 
?> 

This example would be called from a page with a tag like: <img src="button.php3?text"> The 
above button.phpS script then takes this "text" string an overlays it on top of a base image which in 
this case is "images/buttonl. gif" and outputs the resulting image. This is a very convenient way to 
avoid having to draw new button images every time you want to change the text of a button. With 
this method they are dynamically generated. 

Prev Home Next 

Error handling Ug HTTP authentication with PHP 







exit 




} 


else 
echo 
echo 




} 




9 


> 





PHP Manual 

Prev Next 

Chapter 16. HTTP authentication with PHP 

The HTTP Authentication hooks in PHP are only available when it is running as an Apache module and is hence not 
available in the CGI version. In an Apache module PHP script, it is possible to use the HeaderQ function to send an 
"Authentication Required" message to the client browser causing it to pop up a Username/Password input window. Once 
the user has filled in a username and a password, the URL containing the PHP script will be called again with the 
variables, $PHP_AUTH_USER, $PHP_AUTH_PW and $PHP_AUTH_TYPE set to the user name, password and 
authentication type respectively. Only "Basic" authentication is supported at this point. See the HeaderQ function for 
more information. 

An example script fragment which would force client authentication on a page would be the following: 

Example 16-1, HTTP Authentication example 

<?php 

if ( ! isset ($PHP_AUTH_USER) ) { 

Header ("www-Authenticate : Basic realm=\"My Realm\""); 

Header ("HTTP/1.0 401 Unauthorized"); 

echo "Text to send if user hits Cancel button\n"; 

{ 

"Hello $PHP_AUTH_USER.<P>"; 

"You entered $PHP_AUTH_PW as your password. <P>" ; 



Instead of simply printing out the $PHP_AUTH_USER and $PHP_AUTH_PW, you would probably want to check the 
username and password for validity. Perhaps by sending a query to a database, or by looking up the user in a dbm file. 

Watch out for buggy Internet Explorer browsers out there. They seem very picky about the order of the headers. Sending 
the WWW -Authentic ate header before the HTTP/1.0 401 header seems to do the trick for now. 

In order to prevent someone from writing a script which reveals the password for a page that was authenticated through a 
traditional external mechanism, the PHP_AUTH variables will not be set if external authentication is enabled for that 
particular page. In this case, the $REMOTE_USER variable can be used to identify the externally-authenticated user. 

Note, however, that the above does not prevent someone who controls a non-authenticated URL from stealing passwords 
from authenticated URLs on the same server. 

Both Netscape and Internet Explorer will clear the local browser window's authentication cache for the realm upon 
receiving a server response of 401. This can effectively "log out" a user, forcing them to re-enter their username and 
password. Some people use this to "time out" logins, or provide a "log-out" button. 

Example 16-2, HTTP Authentication example forcing a new name/password 

<?php 

function authenticate ( ) { 

Header ( "WWW-authenticate : basic realm='Test Authentication System'"); 
Header ( "HTTP/1.0 401 Unauthorized"); 

echo "You must enter a valid login ID and password to access this 
resource\n" ; 
exit; 
} 

if (! isset ($PHP_AUTH_USER) M ($SeenBefore == 1 && ! strcmp ($01dAuth, 
$PHP_AUTH_USER) ) ) { 
authenticate ( ) ; 



} 

else { 
echo 
echo 
echo 
echo 
echo 
echo 
echo 



"Welcome : $PHP_AUTH_USER<BR>" ; 

"Old: $01dAuth"; 

"<FORM ACTION=\"$PHP_SELF\" METHOD=POST>\n" ; 

"<INPUT TYPE=HIDDEN NAME = \ "SeenBef ore\ " VALUE = \ "1\ ">\n" ; 

"<INPUT TYPE=HIDDEN NAME=\ "01dAuth\ " VALUE=\ " $PHP_AUTH_USER\ ">\n" ; 

"<INPUT TYPE=Submit VALUE=\"Re Authenticate\ ">\n" ; 

"</FORM>\n"; 



?> 



This behavior is not required by the HTTP Basic authentication standard, so you should never depend on this. Testing with 
Lynx has shown that Lynx does not clear the authentication credentials with a 401 server response, so pressing back and 
then forward again will open the resource (as long as the credential requirements haven't changed). 

Also note that this does not work using Microsoft's IIS server and the CGI version of PHP due to a limitation of IIS. 



Prev 

Creating GIF images 



Home 
Up 



Next 
Cookies 



PHP Manual 

Prev Next 



Chapter 17. Cookies 



PHP transparently supports HTTP cookies. Cookies are a mechanism for storing data in the remote 
browser and thus tracking or identifying return users. You can set cookies using the setcookieQ 

function. Cookies are part of the HTTP header, so setcookieQ must be called before any output is 

sent to the browser. This is the same limitation that headerQ has. 

Any cookies sent to you from the client will automatically be turned into a PHP variable just like 
GET and POST method data. If you wish to assign multiple values to a single cookie, just add [] to 
the cookie name. For more details see the setcookieQ function. 

Prev Home Next 

HTTP authentication with PHP Up Handling file uploads 



PHP Manual 

Prev Next 



rename 

rename ~ rename a file 

Description 

int rename(string oldname, string newname); 
Attempts to rename oldname to newname. 
Returns true on success and false on failure. 

Prev Home Next 

readlink Up rewind 



PHP Manual 

Prev Next 



symlink 



symlink ~ Create a symbolic link 

Description 

int symlink(string target, string link); 

symlinkO creates a symbolic link from the existing target with the specified name link. 

See also linkQ to create hard links, and readlinkQ along with linkinfoQ . 

Prev Home Next 

Istat lj£ tempnam 



PHP Manual 

Prev Next 



linkinfo 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Unkinfo ~ Get information about a Hnk 

Description 

int linkinf o(string path); 

LinkinfoQ returns the st_dev field of the UNIX C stat structure returned by the Istat system call. 
This function is used to verify if a link (pointed to by path) really exists (using the same method 
as the S_ISLNK macro defined in stat.h). Returns or FALSE in case of error. 

See also symlinkQ , linkQ , and readlinkQ . 

Prev Home Next 

link Ug mkdir 



PHP Manual 

Prev Next 



fsockopen 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fsockopen ~ Open Internet or Unix domain socket connection. 

Description 

int f sockopen(string hostname, int port, int [errno], string [errstr], double [timeout]); 

Initiates a stream connection in the Internet (AF_INET) or Unix (AF_UNIX) domain. For the 
Internet domain, it will open a TCP socket connection to hostname on port port. For the Unix 
domain, hostname will be used as the path to the socket, port must be set to in this case. The 
optional timeout can be used to set a timeout in seconds for the connect system call. 

fsockopenO returns a file pointer which may be used together with the other file functions (such as 
fgetsQ , fgetssQ , fputsQ , fcloseQ , feofQ ). 

If the call fails, it will return false and if the optional errno and errstr arguments are present 
they will be set to indicate the actual system level error that occurred on the system-level connect() 
call. If the returned errno is and the function returned false, it is an indication that the error 
occurred before the connect() call. This is most likely due to a problem initializing the socket. Note 
that the errno and errstr arguments must be passed by reference. 

Depending on the environment, the Unix domain or the optional connect timeout may not be 
available. 

The socket will by default be opened in blocking mode. You can switch it to non-blocking mode by 
using set_socket_blocking(). 



Example 1. fsockopen example 

$fp = fsockopen ( "www. php . net " , 80, &$errno, &$errstr, 30); 

if(!$fp) { 

echo "$errstr ($errno) <br>\n" ; 
} else { 

fputs ($fp, "GET / HTTP/1.0\n\n") ; 

while ( !feof($fp) ) { 

echo f gets ( $fp, 128 ) ; 

} 

f close ($fp) ; 
} 

See also: pfsockopenQ 

Prev Home Next 

debugger_on Ug gethostbyaddr 



PHP Manual 

Prev Next 



file_exists 

file_exists ~ Check whether a file exists. 

Description 

i n t f i 1 e_e x i s t s (string filename) ; 

Returns true if the file specified by filename exists; false otherwise. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

file Up fileatime 



PHP Manual 

Prev Next 



flock 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

flock ~ portable advisory file locking 

Description 

bool f lock(int fp, int operation); 

PHP supports a portable way of locking complete files in an advisory way (which means all 
accessing programs have to use the same way of locking or it will not work). 

flockO operates on fp which must be an open file pointer, operation is one of the following 
values: 

q To acquire a shared lock (reader), set operation to 1. 

q To acquire an exclusive lock (writer), set operation to 2. 

q To release a lock (shared or exclusive), set operation to 3. 

q If you don't want flock() to block while locking, add 4 to operation. 

flockO allows you to perform a simple reader/writer model which can be used on virtually every 
platform (including most Unices and even Windows). 

flockO returns true on success and false on error (e.g. when a lock could not be acquired). 

Prev Home Next 

filetype Up fopen 



PHP Manual 

Prev Next 



fclose 

fclose ~ close an open file pointer 

Description 

int f close(int fp); 

The file pointed to by fp is closed. 

Returns true on success and false on failure. 

The file pointer must be valid, and must point to a file successfully opened by fopenQ or 
fsockopenQ . 

Prev Home Next 

diskfreespace U^ feof 



PHP Manual 

Prev Next 



filepro_rowcount 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro_rowcount ~ find out how many rows are in a filePro database 

Description 

int f ilepro_rowcount(void); 

Returns the number of rows in the opened filePro database. 

See also fileproQ . 

Prev Home Next 

filepro_fieldcount U^ Filesystem functions 



PHP Manual 

Prev Next 



basename 

basename ~ return filename component of path 

Description 

string basename(string path); 

Given a string containing a path to a file, this function will return the base name of the file. 

On Windows, both slash (/) and backslash (\) are used as path separator character. In other 
environments, it is the forward slash (/). 

Example 1. basename() example 

$path = " /home/httpd/html/index .php3" ; 

$file = basename ($path) ; // $file is set to "index. php3" 

See also: dirnameQ 

Prev Home Next 

Filesystem functions Up chgrp 



PHP Manual 

Prev Next 



chgrp 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



chgrp ~ change file group 

Description 

int chgrp(string filename, mixed group); 

Attempts to change the group of the file filename to group. Only the superuser may change the 
group of a file arbitrarily; other users may change the group of a file to any group of which that user 
is a member. 

Returns true on success; otherwise returns false. 

On Windows, does nothing and returns true. 

See also chownQ and chmodQ . 

Prev Home Next 

basename Up chmod 



PHP Manual 

Prev Next 



chmod 




chmod — change file mode 

Description 

int chmod(string filename, int mode); 

Attempts to change the mode of the file specified by filename to that given in mode. 

Note that mode is not automatically assumed to be an octal value. To ensure the expected operation, you need 
to prefix mode with a zero (0): 

chmod ( " /somedir/somef ile" , 755 ) ; // decimal; probably incorrect 
chmod ( " /somedir/somef ile" , 0755 ); // octal; correct value of mode 

Returns true on success and false otherwise. 
See also chownQ and chgrpQ . 

Prev Home Next 

chgrp Ug chown 



PHP Manual 

Prev Next 



chown 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



chown ~ change file owner 

Description 

int chown(string filename, mixed user); 

Attempts to change the owner of the file filename to user user. Only the superuser may change the 
owner of a file. 

Returns true on success; otherwise returns false. 

Note: On Windows, does nothing and returns true. 

See also chownQ and chmodQ . 

Prev Home Next 

chmod Up clearstatcache 



PHP Manual 

Prev Next 



clearstatcache 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

clearstatcache ~ clear file stat cache 

Description 

void clearstatcache(void); 



Invoking the stat or Istat system call on most systems is quite expensive. Therefore, the result of the 
last call to any of the status functions (listed below) is stored for use on the next such call using the 
same filename. If you wish to force a new status check, for instance if the file is being checked 
many times and may change or disappear, use this function to clear the results of the last call from 
memory. 

This value is only cached for the lifetime of a single request. 

Affected functions include statQ , IstatQ , file_exists() , is_writeable() , is_readable() , 
is_executable() , is_file() , is_dir() , is_link() , filectimeQ , fileatimeQ , filemtimeQ , fileinodeQ , 
filegroupO , fileownerQ , filesizeQ , filetypeQ , and filepermsQ . 

Prev Home Next 

chown Ug copy 



PHP Manual 

Prev Next 



copy 

copy ~ copy file 

Description 



int copy(string source, string dest); 

Makes a copy of a file. Returns true if the copy succeeded, false otherwise. 
Example 1. copyO example 

if ( !copy ($file, $f ile . ' .bak ' ) ) { 

print ( "failed to copy $f ile . . . <br>\n" ) ; 
} 

See also: renameQ 

Prev Home Next 

clearstatcache Up delete 



PHP Manual 

Prev Next 



delete 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



delete ~ a dummy manual entry 

Description 

void delete(string file); 

This is a dummy manual entry to satisfy those people who are looking for unlinkQ or unsetQ in the 
wrong place. 

See also: unlinkQ to delete files, unsetQ to delete variables. 

Prev Home Next 

copy U^ dirname 



PHP Manual 

Prev Next 



dirname 

dirname ~ return directory name component of path 

Description 

string dirname(string path); 

Given a string containing a path to a file, this function will return the name of the directory. 

On Windows, both slash (/) and backslash (\) are used as path separator character. In other 
environments, it is the forward slash (/). 

Example 1. dirname() example 

$path = " /etc/passwd" ; 

$file = dirname ($path) ; // $file is set to "/etc" 

See also: basenameQ 

Prev Home Next 

delete Up diskfreespace 



PHP Manual 

Prev Next 



diskfreespace 

Ehis function is not supported in the^^f 
HP Lite edition. ~^H 

ossible workaround not yet publis^^H 

diskfreespace — return available space in directory 

Description 

float diskf reespace(string directory); 

Given a string containing a directory, this function will return the number of bytes available on the corresponding 
disk. 

Example 1. diskfreespace() example 

$df = diskf reespace ("/") ; // $df contains the number of bytes available on "/" 

Prev Home Next 

dirname U^ fclose 



PHP Manual 

Prev Next 



feof 

feof ~ test for end-of-file on a file pointer 

Description 

int feof(intfp); 

Returns true if the file pointer is at EOF or an error occurs; otherwise returns false. 

The file pointer must be valid, and must point to a file successfully opened by fopenQ , popenQ , or 
fsockopenQ . 

Prev Home Next 

fclose Up fgetc 



PHP Manual 

Prev Next 



fgetc 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fgetc ~ get character from file pointer 

Description 

string f getc(int fp); 

Returns a string containing a single character read from the file pointed to by fp. Returns FALSE on 
EOF (as does feofQ ). 

The file pointer must be valid, and must point to a file successfully opened by fopenQ , popenQ , or 
fsockopenQ . 

See also freadQ , fopenQ , popenQ , fsockopenQ , and fgetsQ . 

Prev Home Next 

feof Up fgetc sv 



PHP Manual 

Prev Next 



fgetcsv 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fgetcsv ~ get Hne from file pointer and parse for CSV fields 

Description 

array f getcsv(int fp, int length, string [delimiter]); 

Similar to fgets() except that fgetcsv() parses the line it reads for fields in CSV format and returns 
an array containing the fields read. The field delimiter is a comma, unless you specifiy another 
delimiter with the optional third parameter. 

fp must be a valid file pointer to a file successfully opened by fopenQ , popenQ , or fsockopenQ 

length must be greater than the longest line to be found in the CSV file (allowing for trailing 
line-end characters). 

fgetcsvO returns false on error, including end of file. 

NB A blank line in a CSV file will be returned as an array comprising just one single null field, and 
will not be treated as an error. 

Example 1. fgetcsv() example - Read and print entire contents of a CSV file 

$row=l ; 

$fp = f open ( "test . CSV" , "r" ) ; 

while ($data = fgetcsv ($fp, 1000, ",")) { 

$num = count ($data) ; 

print "<p> $num fields in line $row: <br>"; 

$row++; 

for ( $c=0; $c<$num; $c++ ) print $data[$c] . "<br>"; 

} 

f close ($fp) ; 



Prev Home Next 

fgetc IJ£ fgets 



PHP Manual 

Prev Next 



fileatime 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fileatime ~ get last access time of file 

Description 

int fileatime (string filename); 

Returns the time the file was last accessed, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

file_exists Ug filectime 



PHP Manual 

Prev Next 



filectime 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filectime ~ get inode change time of file 

Description 

int filectime (string filename); 

Returns the time the file was last changed, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

fileatime Ug filegroup 



PHP Manual 

Prev Next 



filegroup 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



filegroup ~ get file group 

Description 

int filegroup(string filename); 

Returns the group ID of the owner of the file, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

filectime Ug fileinode 



PHP Manual 

Prev Next 



fileinode 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



fileinode ~ get file inode 

Description 

int fileinode(string filename); 

Returns the inode number of the file, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

filegroup Ug filemtime 



PHP Manual 

Prev Next 



filemtime 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filemtime ~ get file modification time 

Description 

int filemtime(string filename); 

Returns the time the file was last modified, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

fileinode Ug fileowner 



PHP Manual 

Prev Next 



fileowner 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



fileowner — get file owner 

Description 

int fileowner(string filename); 

Returns the user ID of the owner of the file, or false in case of an 

The results of this function are cached. See clearstatcacheQ for more details, error. 

Prev Home Next 

filemtime Ug fileperms 



PHP Manual 

Prev Next 



fileperms 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



fileperms ~ get file permissions 

Description 

int fileperms(string filename); 

Returns the permissions on the file, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

fileowner Ug filesize 



PHP Manual 

Prev Next 



filesize 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



filesize ~ get file size 

Description 

int filesize(string filename); 

Returns the size of the file, or false in case of an error. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

fileperms Ug filetype 



PHP Manual 

Prev Next 



filetype 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



filetype ~ get file type 

Description 



string filetype (string filename) ; 

Returns the type of the file. Possible values are fifo, char, dir, block, link, file, and unknown. 

Returns false if an error occurs. 

The results of this function are cached. See clearstatcacheQ for more details. 

Prev Home Next 

filesize Up flock 



PHP Manual 

Prev Next 



fread 

fread ~ Binary-safe file read 

Description 

string f read(int fp, int length); 

freadO reads up to length bytes from the file pointer referenced by fp. Reading stops when 
length bytes have been read or EOF is reached, whichever comes first. 

// get contents of a file into a string 

$filename = " /usr/local/something . txt " ; 

$fd = f open ( $filename, "r" ); 

$contents = f read ( $fd, f ilesize ( $filename ) ); 

f close ( $fd ) ; 

See also fwriteQ , fopenQ , fsockopenQ , popenQ , fgetsQ , fgetssQ , fileQ , and fpassthruQ . 

Prev Home Next 

fputs Up fseek 



PHP Manual 

Prev Next 



fseek 

fseek ~ seek on a file pointer 

Description 

int f seek(int fp, int offset); 

Sets the file position indicator for the file referenced by fp to offset bytes into the file stream. 
Equivalent to calling (in C) fseek ( fp, offset, SEEK_SET ). 

Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an 
error. 

May not be used on file pointers returned by fopenQ if they use the "http://" or "ftp://" formats. 
See also ftellQ and rewindQ . 

Prev Home Next 

fread Up ftell 



PHP Manual 

Prev Next 



ftell 

ftell ~ tell file pointer read/write position 

Description 

int ftell(int fp); 

Returns the position of the file pointer referenced by fp; i.e., its offset into the file stream. 

If an error occurs, returns false. 

The file pointer must be valid, and must point to a file successfully opened by fopenQ or popenQ . 

See also fopenQ , popenQ , fseekQ and rewindQ . 

Prev Home Next 

fseek Up fwrite 



PHP Manual 

Prev Next 



fwrite 

fwrite ~ Binary-safe file write 

Description 

int f write(int fp, string string, int [lengtfi]); 

fwriteO writes the contents of string to the file stream pointed to by fp. If the length 
argument is given, writing will stop after length bytes have been written or the end of string is 
reached, whichever comes first. 

Note that if the length argument is given, then the magic_quotes_runtime configuration option 
will be ignored and no slashes will be stripped from string. 

See also freadQ , fopenQ , fsockopenQ , popenQ , and fputsQ . 

Prev Home Next 

ftell Up set_file_buffer 



PHP Manual 

Prev Next 



set_file_buffer 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

set_file_buffer ~ Sets file buffering on the given file pointer 

Description 

int f write(int fp, int buffer); 

set_file_buffer() sets the buffering for write operations on the given filepointer fp to buffer 
bytes. If buffer is then write operations are unbuffered. 

The function returns on success, or EOF if the request cannot be honored. 

Note that the default for any fopen with calling set_file_buffer is 8K. 

See also fopenQ . 

Prev Home Next 

fwrite Up is_dir 



PHP Manual 

Prev Next 



is_dir 

is_dir ~ tells whether the filename is a directory 

Description 

bool is_dir (string filename); 

Returns true if the filename exists and is a directory. 

The results of this function are cached. See clearstatcacheQ for more details. 

See also is_file() and is_link() . 

Prev Home Next 

set_file_buffer Up is_executable 



PHP Manual 

Prev Next 



is_executable 

is_executable ~ tells whether the filename is executable 

Description 

bool is_executable(string filename); 

Returns true if the filename exists and is executable. 

The results of this function are cached. See clearstatcacheQ for more details. 

See also is_file() and is_link() . 

Prev Home Next 

is_dir Up is_file 



PHP Manual 

Prev Next 



is_file 

is_file ~ tells whether the filename is a regular file 

Description 

bool is_file(string filename); 

Returns true if the filename exists and is a regular file. 

The results of this function are cached. See clearstatcacheQ for more details. 

See also is_dir() and is_link() . 

Prev Home Next 

is_executable Up is_link 



PHP Manual 

Prev Next 



isjink 

is_link ~ tells whether the filename is a symbolic link 

Description 

bool is_link(string filename); 

Returns true if the filename exists and is a symbolic link. 

The results of this function are cached. See clearstatcacheQ for more details. 

See also is_dir() and is_file() . 

Prev Home Next 

is_file Up is_readable 



PHP Manual 

Prev Next 



is_readable 

is_readable ~ tells whether the filename is readable 

Description 

bool i s_r e a dab le (string filename); 

Returns true if the filename exists and is readable. 

Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 
'nobody'). Safe mode limitations are not taken into account. 

The results of this function are cached. See clearstatcacheQ for more details. 
See also is_writeable() . 

Prev Home Next 

is_link U^ is_writeable 



PHP Manual 

Prev Next 



is_writeable 

is_writeable ~ tells whether the filename is writeable 

Description 

bool is_writeable(string filename); 

Returns true if the filename exists and is writeable. The filename argument may be a directory 
name allowing you to check if a directory is writeable. 

Keep in mind that PHP may be accessing the file as the user id that the web server runs as (often 
'nobody'). Safe mode limitations are not taken into account. 

The results of this function are cached. See clearstatcacheQ for more details. 
See also is_readable() . 

Prev Home Next 

is_readable Ug link 



PHP Manual 

Prev Next 



link 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Unk ~ Create a hard Hnk 

Description 

int link(string target, string Hnk); 

LinkQ creates a hard hnk. 

See also the symlinkQ to create soft hnks, and readlinkQ along with linkinfoQ . 

Prev Home Next 

is_writeable Ug linkinfo 



PHP Manual 

Prev Next 



mkdir 

mkdir ~ make directory 

Description 

int mkdir(string pathname, int mode); 

Attempts to create the directory specified by pathname. 

Note that you probably want to specify the mode as an octal number, which means it should have a 
leading zero. 

mkdir ( " /path/to/my/dir " , 0700) ; 
Returns true on success and false on failure. 
See also rmdirQ . 

Prev Home Next 

linkinfo Up pclose 



PHP Manual 

Prev Next 



rewind 

rewind ~ rewind the position of a file pointer 

Description 

int rewind(int fp); 

Sets the file position indicator for fp to the beginning of the file stream. 

If an error occurs, returns 0. 

The file pointer must be valid, and must point to a file successfully opened by fopenQ . 

See also fseekQ and ftellQ . 

Prev Home Next 

rename Up rmdir 



PHP Manual 

Prev Next 



rmdir 

rmdir ~ remove directory 

Description 

int rmdi r (string dimame); 

Attempts to remove the directory named by pathname. The directory must be empty, and the 
relevant permissions must permit this. 

If an error occurs, returns 0. 

See also mkdirQ . 

Prev Home Next 

rewind Up stat 



PHP Manual 

Prev Next 



Stat 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Stat ~ give information about a file 

Description 



array s tat (string filename); 

Gathers the statistics of the file named by filename. 

Returns an array with the statistics of the file with the following elements: 

1. device 

2. inode 

3. inode protection mode 

4. number of links 

5. user id of owner 

6. group id owner 

7. device type if inode device * 

8. size in bytes 

9. time of last access 

10. time of last modification 

1 1 . time of last change 

12. blocksize for filesystem I/O * 

13. number of blocks allocated 

* - only valid on systems supporting the st_blksize type—other systems (i.e. Windows) return -1 

The results of this function are cached. See clearstatcache() for more details. 



Prev Home Next 

rmdir U^ Istat 



PHP Manual 

Prev Next 



Istat 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Istat ~ give information about a file or symboHc Hnk 

Description 

array Istat (string filename) ; 

Gathers the statistics of the file or symbolic link named by filename. This function is identical to 
the statQ function except that if the filename parameter is a symbolic link, the status of the 
symbolic link is returned, not the status of the file pointed to by the symbolic link. 

Returns an array with the statistics of the file with the following elements: 

1. device 

2. inode 

3. number of links 

4. user id of owner 

5. group id owner 

6. device type if inode device * 

7. size in bytes 

8. time of last access 

9. time of last modification 

10. time of last change 

1 1 . blocksize for filesystem I/O * 

12. number of blocks allocated 

* - only valid on systems supporting the st_blksize type—other systems (i.e. Windows) return -1 

The results of this function are cached. See clearstatcacheQ for more details. 



Prev Home Next 

Stat U^ symlink 



PHP Manual 

Prev Next 



tempnam 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

tempnam ~ create unique file name 

Description 

string tempnam(string dir, string prefix); 

Creates a unique temporary filename in the specified directory. If the directory does not exist, 
tempnamO may generate a filename in the system's temporary directory. 

The behaviour of the tempnam() function is system dependent. On Windows the TMP 
environment variable will override the di r parameter, on Linux the TMPDIR environment 
variable has precedence, while S VR4 will always use your di r parameter if the directory it points 
to exists. Consult your system documentation on the tempnam(3) function if in doubt. 

Returns the new temporary filename, or the null string on failure. 
Example 1. tempnam() example 

$tmpfname = tempnam( "/tmp", "FOO" ); 

Prev Home Next 

symlink Ug touch 



PHP Manual 

Prev Next 



touch 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

touch ~ set modification time of file 

Description 

int touch(string filename, int time); 

Attempts to set the modification time of the file named by filename to the value given by time. If 
the option time is not given, uses the present time. 

If the file does not exist, it is created. 

Returns true on success and false otherwise. 

Prev Home Next 

tempnam U^ umask 



PHP Manual 

Prev Next 



umask 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

umask ~ changes the current umask 

Description 



int umask(int mask); 

UmaskQ sets PHP's umask to mask & 0777 and returns the old umask. When PHP is being used as 
a server module, the umask is restored when each request is finished. 

UmaskQ without arguments simply returns the current umask. 

Prev Home Next 

touch Ug unlink 



PHP Manual 

Prev Next 



unlink 

unlink ~ Delete a file 

Description 

int unlink( string filename) ; 

Deletes filename. Similar to the Unix C unlinkQ function. 

Returns or FALSE on an error. 

See also rmdirQ for removing directories. 

Prev Home Next 

umask Ug Forms Data Format functions 



PHP Manual 

Prev Next 



apache_note 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

apache_note ~ Get and set apache request notes 

Description 

string apache_note(string note_name, string [note_value]); 

apache_note() is an Apache- specific function which gets and sets values in a request's notes 
table. If called with one argument, it returns the current value of note not e_name. If called with 
two arguments, it sets the value of note note_name to note_value and returns the previous 
value of note note_name. 

Prev Home Next 

apache_lookup_uri IJ£ getallheaders 



PHP Manual 

Prev Next 



bcadd 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcadd ~ Add two arbitrary precision numbers. 

Description 

string bcadd(string left operand, string right operand, int [scale]); 

Adds the left operand to the right operand and returns the sum in a string. The optional 
scale parameter is used to set the number of digits after the decimal place in the result. 

See also bcsubQ . 

Prev Home Next 

Arbitrary precision mathematics U^ bccomp 

functions 



PHP Manual 

Prev Next 



bccomp 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bccomp ~ Compare two arbitrary precision numbers. 

Description 

int bccomp(string left operand, string right operand, int [scale]); 

Compares the left operand to the right operand and returns the result as an integer. The 
optional scale parameter is used to set the number of digits after the decimal place which will be 
used in the comparion. The return value is if the two operands are equal. If the left operand 
is larger than the ri gh t operand the return value is +1 and if the left operand is less than 
the ri gh t operand the return value is - 1 . 

Prev Home Next 

bcadd U^ bcdiv 



PHP Manual 

Prev Next 



bcdiv 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcdiv ~ Divide two arbitrary precision numbers. 

Description 

string bcdiv(string left operand, string right operand, int [scale]); 

Divides the left operand by the right operand and returns the result. The optional 
scale sets the number of digits after the decimal place in the result. 

See also bcmulQ . 

Prev Home Next 

bccomp Ug bcmod 



PHP Manual 

Prev Next 



bcmod 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcmod ~ Get modulus of an arbitrary precision number. 

Description 

string bcmod(string left operand, string modulus); 
Get the modulus of the left operand using modulus. 
See also bcdivQ . 

Prev Home Next 

bcdiv Ug bcmul 



PHP Manual 

Prev Next 



bcmul 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcmul ~ Multiply two arbitrary precision number. 

Description 

string bcmul(string left operand, string right operand, int [scale]); 

Multiply the left operand by the right operand and returns the result. The optional 
scale sets the number of digits after the decimal place in the result. 

See also bcdivQ . 

Prev Home Next 

bcmod U^ bcpow 



PHP Manual 

Prev Next 



bcpow 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcpow ~ Raise an arbitrary precision number to another. 

Description 

string bcpow(string x, string y, int [scale]); 



Raise x to the power y. The scale can be used to set the number of digits after the decimal place 
in the result. 

See also bcsqrtQ . 

Prev Home Next 

bcmul U^ bcscale 



PHP Manual 

Prev Next 



bcscale 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcscale ~ Set default scale parameter for all be math functions. 

Description 

string bcscale(int scale); 

This function sets the default scale parameter for all subsequent be math functions that do not 
explicitly specify a scale parameter. 

Prev Home Next 

bcpow Up bcsqrt 



PHP Manual 

Prev Next 



bcsqrt 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

bcsqrt ~ Get the square root of an arbitray precision number. 

Description 

string bcsqrt(string operand, int scale); 

Return the square root of the operand. The optional scale parameter sets the number of digits 
after the decimal place in the result. 

See also bcpowQ . 

Prev Home Next 

bcscale U^ bcsub 



PHP Manual 

Prev Next 



bcsub 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



bcsub ~ Subtract one arbitrary precision number from another. 

Description 

string bcsub(string left operand, string right operand, int [scale]); 

Subtracts the right operand from the left operand and returns the result in a string. The 
optional scale parameter is used to set the number of digits after the decimal place in the result. 

See also bcaddQ . 

Prev Home Next 

bcsqrt U^ Array functions 



PHP Manual 

Prev Next 



ada_rollback 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_rollback — rollback a transaction 

Description 

See odbc_rollback(). 



Prev Home Next 

ada_resultall Up Apache- specific functions 



PHP Manual 

Prev Next 



apache_lookup_uri 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



apache_lookup_uri ~ Perform a partial request for the specified URI and return all info about it 

Description 

class ap a che_lookup_uri (string filename); 

This performs a partial request for a URI. It goes just far enough to obtain all the important 
information about the given resource and returns this information in a class. The properties of the 
returned class are: 

status 

the_request 

status_line 

method 

content_type 

handler 

uri 

filename 

path_info 

args 

boundary 

no_cache 

no_local_copy 

allowed 

send_bodyct 

bytes_sent 

byterange 

clength 

unparsed_uri 

mtime 

request_time 

Note: Note: apache_lookup_uri only works when PHP is installed as an Apache 



module 



Prev Home Next 

Apache-specific functions Ug apaclie_note 



PHP Manual 

Prev Next 



mssql_result 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mssql_result ~ get result data 

Description 

int mssql_result(int result, int i, mixed field); 

Returns: The contents of the cell at the row and offset in the specified MS SQL result set. 

mssql_result() returns the contents of one cell from a MS SQL result set. The field argument can be 
the field's offset, or the field's name, or the field's table dot field's name (fieldname. tablename). If 
the column name has been aliased ('select foo as bar from...'), use the alias instead of the column 
name. 

When working on large result sets, you should consider using one of the functions that fetch an 
entire row (specified below). As these functions return the contents of multiple cells in one function 
call, they're MUCH quicker than mssql_result(). Also, note that specifying a numeric offset for the 
field argument is much quicker than specifying a fieldname or tablename.fieldname argument. 

Recommended high-performance alternatives: mssql_fetch_row() , mssql_fetch_array() , and 
mssql_fetch_object() . 

Prev Home Next 

mssqLquery Up mssql_select_db 



PHP Manual 

Prev Next 



mssql_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_connect ~ open MS SQL server connection 

Description 

int mssql_connect(string servername, string username, string password); 

Returns: A positive MS SQL Hnk identifier on success, or false on error. 

mssql_connect() estabhshes a connection to a MS SQL server. The servername argument has to be 
a vaUd servername that is defined in the 'interfaces' file. 

In case a second call is made to mssql_connect() with the same arguments, no new link will be 
established, but instead, the link identifier of the already opened link will be returned. 

The link to the server will be closed as soon as the execution of the script ends, unless it's closed 
earlier by explicitly calling mssql_close() . 

See also mssql_pconnect() , mssql_close() . 

Prev Home Next 

mssql_close Up mssql_data_seek 



PHP Manual 

Prev Next 



mssql_query 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssqLquery ~ send MS SQL query 

Description 

int ms sql_query(string query, int Hnk_identifier); 

Returns: A positive MS SQL result identifier on success, or false on error. 

mssql_query() sends a query to the currently active database on the server that's associated with the 
specified link identifier. If the link identifier isn't specified, the last opened link is assumed. If no 
link is open, the function tries to establish a link as if mssql_connect() was called, and use it. 

See also: mssql_db_query(), mssql_select_db() , and mssql_connect() . 

Prev Home Next 

mssqLpconnect Up mssql_result 



PHP Manual 

Prev Next 



mssql_pconnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssqLpconnect ~ open persistent MS SQL connection 

Description 

int mssql_pconnect(string servername, string username, string password); 
Returns: A positive MS SQL persistent Hnk identifier on success, or false on error 
mssql_pconnect() acts very much hke mssql_connect() with two major differences. 

First, when connecting, the function would first try to find a (persistent) link that's already open 
with the same host, username and password. If one is found, an identifier for it will be returned 
instead of opening a new connection. 

Second, the connection to the SQL server will not be closed when the execution of the script ends. 
Instead, the link will remain open for future use ( mssql_close() will not close links established by 

mssql_pconnect ( ) ). 

This type of links is therefore called 'persistent'. 

Prev Home Next 

mssql_num_rows U^ mssql_query 



PHP Manual 

Prev Next 



ImageArc 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImageArc ~ draw a partial elHpse 

Description 

int imagearc(int im, int ex, int cy, int w, int h, int s, int e, int col); 

ImageArc draws a partial ellipse centered at ex, cy (top left is 0,0) in the image represented by im. 
w and h specifies the ellipse's width and height respectively while the start and end points are 
specified in degrees indicated by the s and e arguments. 

Prev Home Next 

GetlmageSize Ug ImageChar 



PHP Manual 

Prev Next 



ldap_errno 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ldap_errno ~ Return the LDAP error number of the last LDAP command 

Description 

int ldap_errno(int Hnk_id); 

return the LDAP error number of the last LDAP command for this link. 

This function returns the standardized error number returned by the last LDAP command for the 
given link identifier. This number can be converted into a textual error message using 
ldap_err2str() . 

Unless you lower your warning level in your php3.ini sufficiently or prefix your LDAP commands 
with @ (at) characters to suppress warning output, the errors generated will also show up in your 
HTML output. 

Example 1. Generating and catching an error 

<?php 

// This example contains an error, which we will catch. 

$ld = ldap_connect ( "localhost " ) ; 

$bind = ldap_bind ( $ld) ; 

// syntax error in filter expression (errno 87), 

// must be "ob jectclass=* " to work. 

$res = @ldap_search ($ld, "o=Myorg, c=DE", "ob jectclass" ) ; 

if (!$res) { 

printf ( "LDAP-Errno : %s<br>\n", ldap_errno ( $ld) ) ; 

printf ( "LDAP-Error : %s<br>\n", ldap_error ($ld) ) ; 

die ("Argh! <br>\n") ; 

} 

$info = ldap_get_entries ( $ld, $res); 

printf ("%d matching entries . <br>\n" , $inf o [ "count "]) ; 

?> 

see also ldap_err2str() and ldap_error() . 



Prev Home Next 

ldap_err2str U^ ldap_error 



PHP Manual 

Prev Next 



Idap_err2str 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ldap_err2str ~ Convert LDAP error number into string error message 

Description 

string ldap_err2str(int errno); 

returns string error message. 

This function returns the string error message explaining the error number errno. While LDAP 
errno numbers are standardized, different libraries return different or even localized textual error 
messages. Never check for a specific error message text, but always use an error number to check. 

see also ldap_errno() and ldap_error() . 

Example 1. Enumerating all LDAP error messages 

<?php 

for($i=0; $i<100; $i++) { 

printf ( "Error $i: %s<br>\n", ldap_str2err ($i) ) ; 

} 
?> 

Prev Home Next 

ldap_unbind U^ ldap_errno 



PHP Manual 

Prev Next 



strval 

strval ~ Get string value of a variable. 

Description 

string strval(mixed var); 

Returns the string value of var. 

var may be any scalar type. You cannot use strvalQ on arrays or objects. 

See also double valQ , intvalQ , settypeQ and Type juggling . 

Prev Home Next 

settype Up unset 



PHP Manual 

Prev Next 



isset 

isset ~ determine whether a variable is set 

Description 

int i s set (mixed var); 

Returns true if var exists; false otherwise. 

If a variable has been unset with unsetQ , it will no longer be isset(). 

$a = "test"; 

echo isset ($a); // true 

unset ( $a) ; 

echo isset ($a); // false 

See also emptyQ and unsetQ . 

Prev Home Next 

is_string U^ settype 



PHP Manual 

Prev Next 



empty 

empty ~ determine whether a variable is set 

Description 



int empt y (mixed var); 

Returns false if var is set and has a non-empty or non-zero value; true otherwise. 

See also issetQ and unsetQ . 

Prev Home Next 

doubleval Up gettype 



PHP Manual 

Prev Next 



strip_tags 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

strip_tags ~ Strip HTML and PHP tags from a string 

Description 

string strip_tags (string str, string [allowable_tags]); 

This function tries to strip all HTML and PHP tags from the given string. It errors on the side of 
caution in case of incomplete or bogus tags. It uses the same tag stripping state machine as the 
fgetssQ function. 

You can use the optional second parameter to specify tags which should not be stripped. 
Note: allowable_tags was added in PHP 3.0.13, PHP4B3. 

Prev Home Next 

strcspn Ug StripCSlashes 



PHP Manual 

Prev Next 



pg_Result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

pg_Result ~ Returns values from a result identifier 

Description 

mixed pg_result(int result_id, int row_number, mixed fieldname); 

pg_Result() will return values from a result identifier produced by pg_Exec() . The row_number 
and fieldname sepcify what cell in the table of results to return. Row numbering starts from 0. 
Instead of naming the field, you may use the field index as an unquoted number. Field indices start 
from 0. 

PostgreSQL has many built in types and only the basic ones are directly supported here. All forms 
of integer, boolean and oid types are returned as integer values. All forms of float, and real types 
are returned as double values. All other types, including arrays are returned as strings formatted in 
the same default PostgreSQL manner that you would see in the psql program. 

Prev Home Next 

pg_Port Up pg-tty 



PHP Manual 

Prev Next 



readdir 

readdir ~ read entry from directory handle 

Description 

string readdir(int dir_handle); 

Returns the filename of the next file from the directory. The filenames are not returned in any 
particular order. 

Example 1. List all files in the current directory 

<?php 

$handle=opendir ('.'); 
echo "Directory handle: $handle\n"; 
echo "Files :\n"; 

while ($file = readdir ($handle) ) { 
echo "$file\n"; 

} 

closedir ($handle) ; 

?> 

Note that readdir() will return the . and .. entries. If you don't want these, simply strip them out: 

Example 2. List all files in the current directory and strip out . and .. 

<?php 

$handle=opendir ('.'); 

while ($file = readdir ($handle) ) { 

if ($file != "." && $file != "..") { 
echo "$file\n"; 

} 
} 

closedir ($handle) ; 
?> 



Prev Home Next 

opendir Up rewinddir 



PHP Manual 

Prev Next 



imap_alerts 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_alerts ~ This function returns all IMAP alert messages (if any) that have occurred during this 
page request or since the alert stack was reset. 

Description 

array imap_alerts(void ); 

This function returns an array of all of the IMAP alert messages generated since the last 
imap_alerts() call, or the beginning of the page. When imap_alerts() is called, the alert stack is 
subsequently cleared. The IMAP specification requires that these messages be passed to the user. 

Prev Home Next 

imap_errors Ug imap_status 



PHP Manual 

Prev Next 



yp_errno 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

yp_errno ~ Returns the error code of the previous operation. 

Description 

int yp_errno(); 

yp_errno() returns the error code of the previous operation. 

Possible errors are: 

1 args to function are bad 

2 RPC failure - domain has been unbound 

3 can't bind to server on this domain 

4 no such map in server's domain 

5 no such key in map 

6 internal yp server or client error 

7 resource allocation failure 

8 no more records in map database 

9 can't communicate with portmapper 

10 can't communicate with ypbind 

1 1 can't communicate with ypserv 

12 local domain name not set 

13 yp database is bad 

14 yp version mismatch 

15 access violation 

16 database busy 

See also: yp_err_string 

Prev Home Next 

yp_next U^ yp_err_string 



PHP Manual 

Prev Next 



array 

array ~ Create an array 

Description 



array array(...); 

Returns an array of the parameters. The parameters can be given an index with the => operator. 

Note: arrayO is a language construct used to represent Hteral arrays, and not a regular 
function. 

The following example demonstrates how to create a two-dimensional array, how to specify keys 
for associative arrays, and how to skip-and-continue numeric indices in normal arrays. 

Example 1. arrayO example 

$fruits = array ( 

"fruits" => array ( "a"=> "orange ", "b"=> "banana" , "c"=>" apple" ) , 

"numbers" => array (1, 2, 3, 4, 5, 6), 

"holes" => array ( "first " , 5 => "second", "third") 

); 

See also: listQ . 

Prev Home Next 

Array functions U^ array _count_values 



PHP Manual 

Prev Next 



asort 



rhis function is not supported in the 

'HP Lite edition. 

'ossible workaround not yet published 



edj 



asort — Sort an array and maintain index association 

Description 

void asort (array array); 

This function sorts an array such that array indices maintain their correlation with the array elements they 
are associated with. This is used mainly when sorting associative arrays where the actual element order is 
significant. 

Example 1. asort() example 

$ fruits = array ( "d"=>" lemon " , " a"=>" orange " , "b "=> "banana " , " c"=>" apple " ) ; 

asort ($fruits) ; 

for (reset ($fruits) ; $key = key ($f ruits) ; next ($f ruits) ) { 

echo "f ruits [ $key] = ". $f ruits [ $key] . "\n" ; 
} 

This example would display: fruits [c] = apple f ruits [b] = banana fruits [d] = 
lemon fruit s [ a ] = orange The fruits have been sorted in alphabetical order, and the index 
associated with each element has been maintained. 

See also arsortQ , rsortQ , ksortQ , and sortQ . 

Prev Home Next 

arsort Up compact 



PHP Manual 

Prev Next 



arsort 



rhis function is not supported in the 

'HP Lite edition. 

'ossible workaround not yet published 



edj 



arsort — Sort an array in reverse order and maintain index association 

Description 

void arsort (array array); 

This function sorts an array such that array indices maintain their correlation with the array elements they 
are associated with. This is used mainly when sorting associative arrays where the actual element order is 
significant. 

Example 1. arsort() example 

$ fruits = array ( "d"=>" lemon " , " a"=>" orange " , "b "=> "banana " , " c"=>" apple " ) ; 

arsort ($fruits) ; 

for (reset ($fruits) ; $key = key ($f ruits) ; next ($f ruits) ) { 

echo "f ruits [ $key] = ". $f ruits [ $key] . "\n" ; 
} 

This example would display: fruits [a] = orange fruits [d] = lemon fruits [b] = 
banana fruit s [ c ] = apple The fruits have been sorted in reverse alphabetical order, and the 
index associated with each element has been maintained. 

See also: asortQ , rsortQ , ksortQ , and sortQ . 

Prev Home Next 

array_walk Up asort 



PHP Manual 

Prev Next 



ksort 



rhis function is not supported in the 

'HP Lite edition. 

'ossible workaround not yet published 



edj 



ksort — Sort an array by key 

Description 

int ksort (array array); 

Sorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays. 
Example 1. ksort() example 

$fruits = array ( "d"=>" lemon " , "a"=>"orange" , "b"=>"banana" , "c"=>"apple" ) ; 

ksort ($fruits) ; 

for (reset ($fruits) ; $key = key ($f ruits) ; next ($f ruits) ) { 

echo "f ruits [ $key] = ". $f ruits [ $key] . "\n" ; 
} 

This example would display: fruits [a] = orange fruits [b] = banana fruits [c] = 
apple fruits [d] = lemon 

See also asortQ , arsortQ , sortQ , and rsortQ . 

Prev Home Next 

krsort Up list 



PHP Manual 

Prev Next 



rsort 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

rsort ~ Sort an array in reverse order 

Description 



void rsort (array array); 

This function sorts an array in reverse order (highest to lowest). 
Example 1. rsort() example 

$fruits = array ( "lemon" , "orange" , "banana" , "apple" ) ; 

rsort ($fruits) ; 

for (reset ($fruits) ; list ( $key, $value) = each ( $f ruits) ; ) { 

echo "fruits [$key] = ", $value, "\n"; 
} 

This example would display: fruits [ ] = orange fruits[l] = lemon fruits[2] 
= banana fruits [3] = apple The fruits have been sorted in reverse alphabetical order. 

See also: arsortQ , asortQ , ksortQ , sortQ , and usortQ . 

Prev Home Next 

reset Ug shuffle 



PHP Manual 

Prev Next 



sort 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



sort ~ Sort an array 

Description 

void sort (array array); 

This function sorts an array. Elements will be arranged from lowest to highest when this function 
has completed. 

Example 1. sort() example 

$fruits = array ( "lemon" , "orange" , "banana" , "apple" ) ; 

sort ($f ruits) ; 

for (reset ( $fruits) ; $key = key ( $f ruits) ; next ( $f ruits) ) { 

echo "fruits [$key] = ". $f ruits [$key] ." \n" ; 
} 

This example would display: fruits [0] = apple fruits[l] = banana fruits[2] 
= lemon fruits [3] = orange The fruits have been sorted in alphabetical order. 

See also: arsortQ , asortQ , ksortQ , rsortQ , and usortQ . 

Prev Home Next 

sizeof Ug uasort 



PHP Manual 

Prev Next 



uasort 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



uasort ~ Sort an array with a user-defined comparison function and maintain index association 

Description 

void uasort(array array, function cmp_function); 

This function sorts an array such that array indices maintain their correlation with the array 
elements they are associated with. This is used mainly when sorting associative arrays where the 
actual element order is significant. The comparison function is user-defined. 

Prev Home Next 

sort Up uksort 



PHP Manual 

Prev Next 



uksort 



This function is not supported in t 

PHP Lite edition. 

Possible workaround not yet published. 



ished. I 



uksort ~ Sort an array by keys using a user-defined comparison function 

Description 

void uksort(array array, function cmp_function); 

This function will sort the keys of an array using a user-supplied comparison function. If the array 
you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. 

Example 1. uksort() example 

function mycompare ( $a, $b) { 
if ($a == $b) return 0; 
return ($a > $b) ? -1 : 1; 

} 

$a = array (4 => "four", 3 => "three", 20 => "twenty", 10 => "ten"); 

uksort ($a, mycompare); 

while (list ( $key, $value) = each($a)) { 

echo "$key: $value\n"; 
} 
This example would display: 2 : twenty 10: ten 4: four 3: three 

See also: arsortQ , asortQ , uasortQ , ksortQ , rsortQ , and sortQ . 

Prev Home Next 

uasort Up usort 



PHP Manual 

Prev Next 



count 

count ~ count elements in a variable 

Description 

int c ount (mixed var); 

Returns the number of elements in var, which is typically an array (since anything else will have 
one element). 

Returns 1 if the variable is not an array. 

Returns if the variable is not set. 



Warning 



countO may return for a variable that isn't set, but it may also return for a variable that has 
been initialized with an empty array. Use issetQ to test if a variable is set. 



See also: sizeofQ , issetQ , and is_array() . 

Prev Home Next 

compact Up current 



PHP Manual 

Prev Next 



next 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

next ~ Advance the internal array pointer of an array 

Description 

mixed next(array array); 



Returns the array element in the next place that's pointed by the internal array pointer, or false if 
there are no more elements. 

nextO behaves like currentQ , with one difference. It advances the internal array pointer one place 
forward before returning the element. That means it returns the next array element and advances the 
internal array pointer by one. If advancing the internal array pointer results in going beyond the end 
of the element list, next() returns false. 



Warning 



If the array contains empty elements then this function will return false for these elements as well. 
To properly traverse an array which may contain empty elements see the eachQ function. 



See also: currentQ , end() prevQ and resetQ 

Prev Home Next 

list Ug pos 



PHP Manual 

Prev Next 



prev 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

prev ~ Rewind the internal array pointer 

Description 

mixed prev(array array); 



Returns the array element in the previous place that's pointed by the internal array pointer, or false 
if there are no more elements. 



Warning 



If the array contains empty elements then this function will return false for these elements as well. 
To properly traverse an array which may contain empty elements see the eachQ function. 



prevO behaves just like nextQ , except it rewinds the internal array pointer one place instead of 
advancing it. 

See also: currentQ , end() nextQ and resetQ 

Prev Home Next 

pos U^ range 



PHP Manual 

Prev Next 

array_count_values 

Inis function is not supported in me^^f 
HP Lite edition. ^^ 

ossible workaround not yet published. I 

array_count_values ~ Counts all the values of an array 

Description 

array array_count_values(array input); 

array _count_values() returns an array using the values of the input array as keys and their frequency in input as 
values. 

Example 1. array _count_values() example 

$array = array ( 1, "hello" , 1, "world" , "hello" ) ; 

array_count_values ( $array) ; // returns array (1=>2, "hello"=>2, "world"=>l) 

Note: This function was added in PHP 4.0. 

Prev Home Next 

array Up array_flip 



PHP Manual 

Prev Next 



compact 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

compact ~ Create array containing variables and their values 

Description 

array compact (string varname I array varnames, [...]); 

compactO takes a variable number of parameters. Each parameter can be either a string containing 
the name of the variable, or an array of variable names. The array can contain other arrays of 
variable names inside it; compact() handles it recursively. 

For each of these, compact() looks for a variable with that name in the current symbol table and 
adds it to the output array such that the variable name becomes the key and the contents of the 
variable become the value for that key. In short, it does the opposite of extractQ . It returns the 
output array with all the variables added to it. 
Example 1. compact() example 

$city = "San Francisco"; 

$ state = "CA"; 

$ event = "SIGGRAPH"; 

$location_vars = array ( "city" , "state"); 

$result = compact ( "event " , $location_vars) ; 

After this, $result will be arrayC'event" => "SIGGRAPH", "city" => "San Francisco", "state" => 
"CA"). 



See also extractQ . 

Note: This function was added in PHP 4.0. 

Prev Home Next 

asort IJ£ count 



PHP Manual 

Prev Next 



krsort 



rhis function is not supported in the 

'HP Lite edition. 

'ossible workaround not yet published 



edj 



krsort — Sort an array by key in reverse order 

Description 

int krsort (array array); 

Sorts an array by key in reverse order, maintaining key to data correlations. This is useful mainly for 
associative arrays. 

Example 1. krsort() example 

$ fruits = array ( "d"=>" lemon " , " a"=>" orange " , "b "=> "banana " , " c"=>" apple " ) ; 

krsort ($fruits) ; 

for (reset ($fruits) ; $key = key ($f ruits) ; next ($f ruits) ) { 

echo "f ruits [ $key] = ". $f ruits [ $key] . "\n" ; 
} 

This example would display: fruits [d] = lemon fruits [c] = apple fruits [b] = 
banana fruits [a] = orange 

See also asortQ , arsortQ , ksortQ sortQ , and rsortQ . 

Prev Home Next 

key Up ksort 



PHP Manual 

Prev Next 



reset 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

reset ~ Set the internal pointer of an array to its first element 

Description 

mixed re set (array array); 

resetO rewinds arrays internal pointer to the first element. 

resetO returns the value of the first array element. 

See also: currentQ , eachQ , nextQ , prevQ , and reset(). 

Prev Home Next 

range Up rsort 



PHP Manual 

Prev Next 



shuffle 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



shuffle ~ Shuffle an array 

Description 

void shuffle(array array); 

This function shuffles (randomizes the order of the elements in) an array. 
Example 1. shuffle() example 

$numbers = range (1,20) ; 

srand (time ( ) ) ; 

shuffle ($numbers) ; 

while (list ( , $number ) = each ($numbers) ) { 

echo "$number "; 
} 

See also arsortQ , asortQ , ksortQ , rsortQ , sortQ and usortQ . 

Prev Home Next 

rsort Up sizeof 



PHP Manual 

Prev Next 



sizeof 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

sizeof ~ Get the number of elements in an array 

Description 

int sizeof (array array); 

Returns the number of elements in the array. 

See also: countQ 

Prev Home Next 

shuffle U^ sort 



PHP Manual 

Prev Next 



current 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

current ~ Return the current element in an array 

Description 

mixed current(array array); 

Every array has an internal pointer to its "current" element, which is initialized to the first element 
inserted into the array. 

The currentO function simply returns the array element that's currently being pointed by the 
internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the 
end of the elements list, current() returns false. 



Warning 



If the array contains empty elements (0 or "", the empty string) then this function will return false 
for these elements as well. This makes it impossible to determine if you are really at the end of the 
list in such an array using current(). To properly traverse an array that may contain empty 
elements, use the eachQ function. 



See also: end() , nextQ , prevQ and resetQ . 

Prev Home Next 

count Up each 



PHP Manual 

Prev Next 



is_array 

is_array ~ Finds whether a variable is an array. 

Description 

int is_array(mixed var); 

Returns true if var is an array, false otherwise. 

See also is_double() , is_float() , is_int() , is_integer() , is_real() , is_string() , is_long() , and 
is_object() . 

Prev Home Next 

intval U2 is_double 



PHP Manual 

Prev Next 



pos 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

pos ~ Get the current element from an array 

Description 

mixed pos (array array); 

This is an ahas for currentQ . 

See also: end(), nextQ, prevQ and resetQ. 



Prev Home Next 

next Up prev 



PHP Manual 

Prev Next 



end 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

end ~ Set the internal pointer of an array to its last element 

Description 

end(array array); 

end() advances arrays internal pointer to the last element. 

See also: currentQ , eachQ , end(), nextQ , and resetQ . 

Prev Home Next 

each U^ extract 



PHP Manual 

Prev Next 



range 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

range ~ Create an array containing a range of integers 

Description 

array range(int low, int high); 

rangeO returns an array of integers from low to high, inclusive. 

See shuffleQ for an example of its use. 

Prev Home Next 

prev U^ reset 



PHP Manual 

Prev Next 



key 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

key ~ Fetch a key from an associative array 

Description 

mixed key(array array); 

keyO returns the index element of the current array position. 

See also: currentQ , nextQ 

Prev Home Next 

in_array U^ krsort 



PHP Manual 

Prev Next 



gettype 

gettype ~ Get the type of a variable. 

Description 

string ge t type (mixed var); 
Returns tlie type of the PHP variable var. 
Possibles values for the returned string are: 

q "integer" 

q "double" 

q "string" 

q "array" 

q "object" 

q "unknown type" 
See also settypeQ . 



Prev Home Next 

empty Up intval 



PHP Manual 

Prev Next 



is_string 

is_string ~ Finds whether a variable is a string. 

Description 

int is_string(mixed var); 

Returns true if var is a. string, false otherwise. 

See also is_long() , is_int() , is_integer() , is_float() , is_double() , is_real() , is_object() , and 
is_array() . 

Prev Home Next 

is_real U^ isset 



PHP Manual 

Prev Next 



doubleval 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

doubleval ~ Get double value of a variable. 

Description 

double doub leval (mixed var); 

Returns the double (floating point) value of var. 

var may be any scalar type. You cannot use doubleval() on arrays or objects. 

See also intvalQ , strvalQ , settypeQ and Type juggling . 

Prev Home Next 

Variable functions Up empty 



PHP Manual 

Prev Next 



intval 

intval ~ Get integer value of a variable. 

Description 

int intval(mixed var, int [base]); 

Returns the integer value of var, using the specified base for the conversion (the default is base 
10). 

var may be any scalar type. You cannot use intval() on arrays or objects. 

See also double valQ , strvalQ , settypeQ and Type juggling . 

Prev Home Next 

gettype U£ is_array 



PHP Manual 

Prev Next 



setcookie 

setcookie ~ Send a cookie 

Description 

int setcookie(string name, string value, int expire, string path, string domain, int secure); 

setcookieO defines a cookie to be sent along with the rest of the header information. Cookies must be sent 
before any other headers are sent (this is a restriction of cookies, not PHP). This requires you to place calls 
to this function before any <html> or <head> tags. 

All the arguments except the name argument are optional. If only the name argument is present, the cookie 
by that name will be deleted from the remote client. You may also replace any argument with an empty 
string ("") in order to skip that argument. The expire and secure arguments are integers and cannot be 
skipped with an empty string. Use a zero (0) instead. The expire argument is a regular Unix time integer 
as returned by the timeQ or mktimeQ functions. The secure indicates that the cookie should only be 
transmitted over a secure HTTPS connection. 

Common Pitfalls: 

Cookies will not become visible until the next loading of a page that the cookie should be visible for. 

Multiple calls to setcookieO in the same script will be performed in reverse order. If you are trying to 
delete one cookie before inserting another you should put the insert before the delete. 

Some examples follow: 

Example 1. setcookieO examples 

setcookie ( "TestCookie" , "Test Value") ; 

setcookie ( "TestCookie" , $value, time +3600 ) ; /* expire in 1 hour */ 

setcookie ( "TestCookie" , $ value, time ( ) +3600, "/~rasmus/ " , " . utoronto . ca" , 1 ) ; 

Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and 
when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie 
name. To see the contents of our test cookie in a script, simply use one of the following examples: 

echo $TestCookie; 

echo $HTTP_COOKIE_VARS ["TestCookie"] ; 

You may also set array cookies by using array notation in the cookie name. This has the effect of setting as 
many cookies as you have array elements, but when the cookie is received by your script, the values are all 
placed in an array with the cookie's name: 

setcookie ( "cookie [three] " , "cookiethree" ); 
setcookie ( "cookie [two] " , "cookietwo" ); 
setcookie ( "cookie [one] " , "cookieone" ) ; 
if ( isset ( $cookie ) ) { 

while ( list ( $name, $value ) = each ( $cookie ) ) { 
echo "$name == $value<br>\n" ; 



} 
} 

For more information on cookies, see Netscape's cookie specification at 
http://www.netscape.com/newsref/std/cookie_spec.html . 

Microsoft Internet Explorer 4 with Service Pack 1 applied does not correctly deal with cookies that have 
their path parameter set. 

Netscape Communicator 4.05 and Microsoft Internet Explorer 3.x appear to handle cookies incorrectly 
when the path and time are not set. 

Prev Home Next 

header Up Hyperwave functions 



PHP Manual 

Prev Next 



header 

header - Send a raw HTTP header 

Description 

int header(string string); 

The HeaderQ function is used at the top of an HTML file to send raw HTTP header strings. See the HTTP 1.1 Specification 
for more information on raw http headers. Note: Remember that the HeaderQ function must be called before any actual 
output is sent either by normal HTML tags or from PHP. It is a very common error to read code with includeQ or with 
auto_prepend and have spaces or empty lines in this code that force output before header() is called. 

There are two special-case header calls. The first is the "Location" header. Not only does it send this header back to the 
browser, it also returns a REDIRECT status code to Apache. From a script writer's point of view this should not be 
important, but for people who understand Apache internals it is important to understand. 

header ( "Location : http://www.php.net"); /* Redirect browser to PHP web site */ 
exit; /* Make sure that code below does not get executed when we redirect. */ 

The second special-case is any header that starts with the string, "HTTP/" (case is not significant). For example, if you have 
your ErrorDocument 404 Apache directive pointed to a PHP script, it would be a good idea to make sure that your PHP 
script is actually generating a 404. The first thing you do in your script should then be: 

header ("http/1 .0 404 Not Found"); 

PHP scripts often generate dynamic HTML that must not be cached by the client browser or any proxy caches between the 
server and the client browser. Many proxies and clients can be forced to disable caching with 

header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past 

header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified 

header ( "Cache-Control : no-cache, must-revalidate" ) ; // HTTP/1.1 

header ("Pragma: no-cache"); // HTTP/1.0 

Prev Home Next 

HTTP functions Up setcookie 



PHP Manual 

Prev Next 



isjong 

is_long ~ Finds whether a variable is an integer. 

Description 

int is_long(mixed var); 

Returns true if var is an integer (long), false otherwise. 

See also is_double() , is_float() , is_int() , is_real() , is_string() , is_object() , is_array() , and 
is_integer() . 

Prev Home Next 

is_integer Ug is_object 



PHP Manual 

Prev Next 



is_double 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

is_double ~ Finds whether a variable is a double. 

Description 

int i s_double (mixed var); 

Returns true if var is a. double, false otherwise. 

See also is_array() , is_float() , is_int() , is_integer() , is_real() , is_string() , is_long() , and 
is_object() . 

Prev Home Next 

is_array Up is_float 



PHP Manual 

Prev Next 



is_object 

is_object ~ Finds whether a variable is an object. 

Description 

int is_ob ject (mixed var); 

Returns true if var is an object, false otherwise. 

See also is_long() , is_int() , is_integer() , is_float() , is_double() , is_real() , is_string() , and 
is_array() . 

Prev Home Next 

is_long Ug is_real 



PHP Manual 

Prev Next 



time 

time ~ return current UNIX timestamp 

Description 

int time(void); 

Returns the current time measured in tlie number of seconds since the Unix Epoch (January 1 1970 
00:00:00 GMT). 

See also dateQ . 

Prev Home Next 

strftime Up dBase functions 



PHP Manual 

Prev Next 



mktime 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mktime ~ get UNIX timestamp for a date 

Description 



int mktime(int hour, int minute, int second, int month, int day, int year, int [is_dst]); 

Warning: Note the strange order of arguments, which differs from the order of arguments in a 
regular UNIX mktime() call and which does not lend itself well to leaving out parameters from 
right to left (see below). It is a common error to mix these values up in a script. 

Returns the Unix timestamp corresponding to the arguments given. This timestamp is a long integer 
containing the number of seconds between the Unix Epoch (January 1 1970) and the time specified. 

Arguments may be left out in order from right to left; any arguments thus omitted will be set to the 
current value according to the local date and time. 

is_dst can be set to 1 if the time is during daylight savings time, if it is not, or -1 (the default) if 
it is unknown whether the time is within daylight savings time or not. 

Note: is_dst was added in 3.0.10. 

mktimeO is useful for doing date arithmetic and validation, as it will automatically calculate the 
correct value for out-of-range input. For example, each of the following lines produces the string 
"Jan-01-1998". 

Example 1. mktime() example 

echo date ( "M-d-Y", mktime ( 0, 0, 0, 12, 32, 1997 ) ) ; 
echo date ( "M-d-Y", mktime ( 0, 0, 0, 13, 1, 1997 ) ); 
echo date ( "M-d-Y", mktime ( 0, 0, 0, 1, 1, 1998 ) ) ; 

See also dateQ and timeQ . 

Prev Home Next 

microtime Up strftime 



PHP Manual 

Prev Next 



isjnteger 

is_integer ~ Find whether a variable is an integer. 

Description 

int i s_integer (mixed var); 
This function is an ahas for is_long() . 

See also is_double() , is_float() , is_int() , is_string() , is_real() , is_object() , is_array() , and 
JsJongQ . 

Prev Home Next 

is_int U2 is_long 



PHP Manual 

Prev Next 



is_float 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

is_float ~ Finds whether a variable is a float. 

Description 

int is_f 1 oat (mixed var); 

This function is an alias for is_double() . 

See also is_double() , is_real() , is_int() , is_integer() , is_string() , is_object() , is_array() , and 
JsJongQ . 

Prev Home Next 

is_double Up is_int 



PHP Manual 

Prev Next 



isjnt 

is_int ~ Find whether a variable is an integer. 

Description 

int i s_int (mixed var); 

This function is an ahas for is_long() . 

See also is_double() , is_float() , is_integer() , is_string() , is_real() , is_object() , is_array() , and 
JsJongQ . 

Prev Home Next 

is_float U2 is_integer 



PHP Manual 

Prev Next 



is_real 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

is_real ~ Finds whether a variable is a real. 

Description 

int is_real(mixed var); 

This function is an alias for is_double() . 

See also is_long() , is_int() , is_integer() , is_float() , is_double() , is_object() , is_string() , and 
is_array() . 

Prev Home Next 

is_object Up is_string 



PHP Manual 

Prev Next 



ereg_replace 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ereg_replace ~ replace regular expression 

Description 

string ere g_r ep 1 ace (string pattern, string replacement, string string) ; 

This function scans stringfor matches to pattern, then replaces the matched text with 

replacement. 

The modified string is returned. (Which may mean that the original string is returned if there are no 
matches to be replaced.) 

If pattern contains parenthesized substrings, replacement may contain substrings of the 
form \\ digit, which will be replaced by the text matching the digit'th parenthesized substring; 
\ \ will produce the entire contents of string. Up to nine substrings may be used. Parentheses may 
be nested, in which case they are counted by the opening parenthesis. 

If no matches are found in string, then string will be returned unchanged. 

For example, the following code snippet prints "This was a test" three times: 

Example 1. ereg_replace() example 

$string = "This is a test"; 

echo ereg_replace ( " is", " was", $string ) ; 
echo ereg_replace ( "( )is", "Wlwas", $string ) ; 
echo ereg_replace ( "(( )is)", "\\2was", $string ) ; 

See also eregO, ereglQ , and eregi_replace() . 

Prev Home Next 

ereg lj£ eregi 



PHP Manual 

Prev Next 



eregi 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

eregi ~ case insensitive regular expression match 

Description 

int eregi(string pattern, string string, array [regs]); 

This function is identical to eregQ save that this ignores case distinction when matching alphabetic 
characters. 

See also eregQ , ereg_replace() , and eregi_replace() . 

Prev Home Next 

ereg_replace U^ eregi_replace 



PHP Manual 

Prev Next 



eregi_replace 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

eregi_replace ~ replace regular expression case insensitive 

Description 

string ereg i_r ep 1 a c e (string pattern, string replacement, string string) ; 

This function is identical to ereg_replace() save that this ignores case distinction when matching 
alphabetic characters. 

See also eregQ , eregiQ , and ereg_replace() . 

Prev Home Next 

eregi U^ split 



PHP Manual 

Prev Appendix B. PHP development Next 



Calling User Functions 



To call user functions from an internal function, you should use the call_user_function() function. 

call_user_function() returns SUCCESS on success, and FAILURE in case the function cannot be 
found. You should check that return value! If it returns SUCCESS, you are responsible for 
destroying the retval pval yourself (or return it as the return value of your function). If it returns 
FAILURE, the value of retval is undefined, and you mustn't touch it. 

All internal functions that call user functions must be reentrant. Among other things, this means 
they must not use globals or static variables. 

call_user_function() takes six arguments: 

HashTable ''function_table 

This is the hash table in which the function is to be looked up. 

pval *object 

This is a pointer to an object on which the function is invoked. This should be NULL if a global 
function is called. If it's not NULL (i.e. it points to an object), the function_table argument is 
ignored, and instead taken from the object's hash. The object *may* be modified by the function 
that is invoked on it (that function will have access to it via $this). If for some reason you don't 
want that to happen, send a copy of the object instead. 



pval *function_name 



The name of the function to call. Must be a pval of type IS_STRING with function_name.str.val 
and function_name.str.len set to the appropriate values. The function_name is modified by 
call_user_function() - it's converted to lowercase. If you need to preserve the case, send a copy of 
the function name instead. 



pval ""retval 



A pointer to a pval structure, into which the return value of the invoked function is saved. The 
structure must be previously allocated - call_user_function() does NOT allocate it by itself. 



int parani_count 

The number of parameters being passed to the function. 

pval ""paramsQ 



An array of pointers to values that will be passed as arguments to the function, the first argument 
being in offset 0, the second in offset 1, etc. The array is an array of pointers to pval's; The pointers 
are sent as-is to the function, which means if the function modifies its arguments, the original 
values are changed (passing by reference). If you don't want that behavior, pass a copy instead. 

Prev Home Next 

PHP development Ug Reporting Errors 



PHP Manual 

Prev Next 



Appendix C. The PHP Debugger 

Table of Contents 

Using the Debugger 

Debugger Protocol 



Using tlie Debugger 



PHP's internal debugger is useful for tracking down evasive bugs. The debugger works by 
connecting to a TCP port for every time PHP starts up. All error messages from that request will be 
sent to this TCP connection. This information is intended for "debugging server" that can run inside 
an IDE or programmable editor (such as Emacs). 

How to set up the debugger: 

1 . Set up a TCP port for the debugger in the configuration file ( debugger.port) and enable it 
( debugger.enabled ). 

2. Set up a TCP listener on that port somewhere (for example socket -1 -s 1400 on UNIX). 

3. In your code, run "debugger_on(hos t)", where host is the IP number or name of the host 
running the TCP listener. 

Now, all warnings, notices etc. will show up on that listener socket, even if you them turned ojfwith 
error _reportingO . 

Prev Home Next 

Reporting Errors Ug Debugger Protocol 



PHP Manual 

Prev Next 



printf 

printf ~ output a formatted string 

Description 



int printf (string format, mixed [args]... ); 

Produces output according to format, which is described in the documentation for sprintfQ . 

See also: printQ , sprintfQ , and flushQ . 

Prev Home Next 

print Up quoted_printable_decode 



PHP Manual 

Prev Next 

Appendix B. PHP development 

Table of Contents 

Adding functions to PHP3 
Calling User Functions 
Reporting Errors 

Adding functions to PHP3 

Function Prototype 

All functions look like this: 

void php3_foo (INTERNAL_FUNCTION_PARAMETERS) { 

} 

Even if your function doesn't take any arguments, this is how it is called. 

Function Arguments 

Arguments are always of type pval. This type contains a union which has the actual type of the argument. So, if your 
function takes two arguments, you would do something like the following at the top of your function: 

Example B-1, Fetching function arguments 

pval *argl, *arg2; 

if (ARG_COUNT (ht) != 2 M getParameters (ht , 2, &argl, &arg2 ) ==FAILURE) { 

WRONG_PARAM_COUNT ; 
} 

NOTE: Arguments can be passed either by value or by reference. In both cases you will need to pass &(pval *) to 
getParameters. If you want to check if the n'th parameter was sent to you by reference or not, you can use the function, 
ParameterPassedByReference(ht,n). It will return either 1 or 0. 

When you change any of the passed parameters, whether they are sent by reference or by value, you can either start over 
with the parameter by calling pval_destructor on it, or if it's an ARRAY you want to add to, you can use functions 
similar to the ones in internal_functions.h which manipulate return_value as an ARRAY. 

Also if you change a parameter to IS_STRING make sure you first assign the new estrdupO'ed string and the string 
length, and only later change the type to IS_STRING. If you change the string of a parameter which already IS_STRING 
or IS_ARRAY you should run pval_destructor on it first. 

Variable Function Arguments 

A function can take a variable number of arguments. If your function can take either 2 or 3 arguments, use the following: 



Example B-2, Variable function arguments 

pval *argl, *arg2, *arg3; 

int arg_count = ARG_COUNT (ht ) ; 

if (arg_count < 2 | | arg_count > 3 | | 

getParameters (ht, arg_count, &argl, &arg2, &arg3) 
WRONG_PARAM_COUNT ; 

} 



=FAILURE) { 



Using the Function Arguments 

The type of each argument is stored in the pval type field. This type can be any of the following 
Table B-1. PHP Internal Types 



IS_STRING String 


IS_DOUBLE Double-precision floating point 


IS_LONG Long integer 


IS_ARRAY Array 


IS_EMPTY None 


IS_USER_FUNCTION ?? 


IS_INTERNAL_FUNCTION ?? (if some of these cannot be passed to a function - delete) 


IS_CLASS ?? 


IS_OBJECT ?? 



If you get an argument of one type and would like to use it as another, or if you just want to force the argument to be of a 
certain type, you can use one of the following conversion functions: 

convert_to_long (argl ) ; 

convert_to_double (argl) ; 

convert_to_string (argl ) ; 

convert_to_boolean_long (argl ) ; /* If the string is "" or "0" it becomes 0, 1 

otherwise */ 

convert_string_to_number (argl ) ; /* Converts string to either LONG or DOUBLE 

depending on string */ 



These function all do in-place conversion. They do not return anything. 
The actual argument is stored in a union; the members are: 

q IS_STRING: argl->value.str.val 

q IS_LONG: argl->value.lval 

q IS_DOUBLE: argl->value.dval 

Memory Management in Functions 

Any memory needed by a function should be allocated with either emalloc() or estrdup(). These are memory handling 
abstraction functions that look and smell like the normal malloc() and strdupO functions. Memory should be freed with 
efree(). 

There are two kinds of memory in this program: memory which is returned to the parser in a variable, and memory 
which you need for temporary storage in your internal function. When you assign a string to a variable which is returned 
to the parser you need to make sure you first allocate the memory with either emalloc() or estrdup(). This memory should 
NEVER be freed by you, unless you later in the same function overwrite your original assignment (this kind of 
programming practice is not good though). 



For any temporary/permanent memory you need in your functions/library you should use the three emalloc(), estrdupO, 
and efree() functions. They behave EXACTLY like their counterpart functions. Anything you emalloc() or estrdupO you 
have to efree() at some point or another, unless it's supposed to stick around until the end of the program; otherwise, 
there will be a memory leak. The meaning of "the functions behave exactly like their counterparts" is: if you efree() 
something which was not emalloc()'ed nor estrdupO'ed you might get a segmentation fault. So please take care and free 
all of your wasted memory. 

If you compile with "-DDEBUG", PHP3 will print out a list of all memory that was allocated using emalloc() and 
estrdupO but never freed with efree() when it is done running the specified script. 

Setting Variables in the Symbol Table 

A number of macros are available which make it easier to set a variable in the symbol table: 
q SET_VAR_STRING(name,value) JH 
q SET_VAR_DOUBLE(name,value) 
q SET_VAR_LONG(name,value) 

m 

Symbol tables in PHP 3.0 are implemented as hash tables. At any given time, &symbol_table is a pointer to the 'main' 
symbol table, and active_symbol_table points to the currently active symbol table (these may be identical like in startup, 
or different, if you're inside a function). 

The following examples use 'active_symbol_table'. You should replace it with &symbol_table if you specifically want to 
work with the 'main' symbol table. Also, the same functions may be applied to arrays, as explained below. 

Example B-3. Checking whether $foo exists in a symbol table 

if (hash_exists (active_symbol_table, "foo", sizeof ( "foo" ) ) ) { exists... } 
else { doesn't exist } 

Example B-4, Finding a variable's size in a symbol table 

hash_f ind ( act ive_symbol_t able, "f oo" , sizeof ( "foo" ) , Spvalue) ; 
check (pvalue .type) ; 

Arrays in PHP 3.0 are implemented using the same hashtables as symbol tables. This means the two above functions can 
also be used to check variables inside arrays. 

If you want to define a new array in a symbol table, you should do the following. 

First, you may want to check whether it exists and abort appropiately, using hash_exists() or hash_find(). 

Next, initialize the array: 

Example B-5, Initializing a new array 

pval arr; 

if (array_init (&arr) == FAILURE) { failed... } ; 

hash_update ( act ive_symbol_t able, "foo", sizeof ("foo") , &arr, sizeof (pval) , NULL) ; 

This code declares a new array, named $foo, in the active symbol table. This array is empty. 
Here's how to add new entries to it: 



Example B-6, Adding entries to a new array 

pval entry; 

entry. type = IS_LONG; 
entry . value . Ival = 5; 

/* defines $foo["bar"] = 5 */ 

hash_update (arr . value .ht, "bar", sizeof ("bar") , Sentry, sizeof (pval) , NULL) ; 

/* defines $foo[7] = 5 */ 

hash_index_update (arr . value .ht, 7, &entry, sizeof (pval) , NULL) ; 

/* defines the next free place in $foo[], 
* $foo[8], to be 5 (works like php2) 

hash_next_index_insert (arr . value . ht , Sentry, sizeof (pval ) , NULL) ; 

If you'd like to modify a value that you inserted to a hash, you must first retrieve it from the hash. To prevent that 
overhead, you can supply a pval ** to the hash add function, and it'll be updated with the pval * address of the inserted 
element inside the hash. If that value is NULL (like in all of the above examples) - that parameter is ignored. 

hash_next_index_insert() uses more or less the same logic as "$foo[] = bar;" in PHP 2.0. 

If you are building an array to return from a function, you can initialize the array just like above by doing: 

if (array_init (return_value) == FAILURE) { failed...; } 

...and then adding values with the helper functions: 

add_next_index_long (return_value, long_value) ; 
add_next_index_double (return_value, double_value) ; 
add_next_index_string (return_value, estrdup (string_value) ) ; 

Of course, if the adding isn't done right after the array initialization, you'd probably have to look for the array first: 

pval *arr; 

if (hash_find(active_symbol_table, "foo", sizeof ("foo") , (void **) &arr) ==FAILURE) { 

can ' t find. . . } 

else { use arr->value .ht . . . } 

Note that hash_find receives a pointer to a pval pointer, and not a pval pointer. 

Just about any hash function returns SUCCESS or FAILURE (except for hash_exists(), which returns a boolean truth 
value). 

Returning simple values 

A number of macros are available to make returning values from a function easier. 
The RETURN_* macros all set the return value and return from the function: 

q RETURN 

q RETURN_FALSE 

q RETURN_TRUE 

q RETURN_L0NG(1) 



q RETURN_STRING(s,dup) If dup is true, duplicates the string 

q RETURN_STRINGL(s,l,dup) Return string (s) specifying length (1). 

q RETURN_DOUBLE(d) 

The RETVAL_* macros set the return value, but do not return. 

q RETVAL_FALSE 

q RETVAL_TRUE 

q RETVAL_L0NG(1) 

q RETVAL_STRING(s,dup) If dup is true, duplicates the string 

q RETVAL_STRINGL(s,l,dup) Return string (s) specifying length (1). 

q RETVAL_DOUBLE(d) 

The string macros above will all estrdupO the passed 's' argument, so you can safely free the argument after calling the 
macro, or alternatively use statically allocated memory. 

If your function returns boolean success/error responses, always use RETURN_TRUE and RETURN_FALSE 
respectively. 

Returning complex values 

Your function can also return a complex data type such as an object or an array. 
Returning an object: 

1. Call object_init(return_value). 

2. Fill it up with values. The functions available for this purpose are listed below. 

3. Possibly, register functions for this object. In order to obtain values from the object, the function would have to 
fetch "this" from the active_symbol_table. Its type should be IS_OBJECT, and it's basically a regular hash table 
(i.e., you can use regular hash functions on .value.ht). The actual registration of the function can be done using: 

add_method ( return_value, function_name, function_ptr ); 

The functions used to populate an object are: 

q add_property_long( return_value, property _name, 1 ) - Add a property named 'property _name', of type long, equal 
toT 

q add_property_double( return_value, property _name, d ) - Same, only adds a double 

q add_property_string( return_value, property_name, str ) - Same, only adds a string 

q add_property_stringl( return_value, property _name, str, 1 ) - Same, only adds a string of length T 

Returning an array: 

1. Call array _init(return_value). 

2. Fill it up with values. The functions available for this purpose are listed below. 
The functions used to populate an array are: 

q add_assoc_long(return_value,key,l) - add associative entry with key 'key' and long value '1' 

q add_assoc_double(return_value,key,d) 

q add_assoc_string(return_value,key,str,duplicate) 



q add_assoc_stringl(return_value,key,str,length,duplicate) specify the string length 

q add_index_long(return_value,index,l) - add entry in index 'index' with long value '1' 

q add_index_double(return_value,index,d) 

q add_index_string(return_value,index,str) 

q add_index_stringl(return_value,index,str,length) - specify the string length 

q add_next_index_long(return_value,l) - add an array entry in the next free offset with long value '1' 

q add_next_index_double(return_value,d) 

q add_next_index_string(return_value, str) 

q add_next_index_stringl(return_value,str,length) - specify the string length 



Using the resource list 



PHP 3.0 has a standard way of dealing with various types of resources. This replaces all of the local linked lists in PHP 
2.0. 

Available functions: 

q php3_list_insert(ptr, type) - returns the 'id' of the newly inserted resource 

q php3_list_delete(id) - delete the resource with the specified id 

q php3_list_find(id,*type) - returns the pointer of the resource with the specified id, updates 'type' to the resource's 
type 

Typically, these functions are used for SQL drivers but they can be used for anything else; for instance, maintaining file 
descriptors. 

Typical list code would look like this: 
Example B-7. Adding a new resource 

RESOURCE *resource; 

/* ...allocate memory for resource and acquire resource... */ 

/* add a new resource to the list */ 

return_value->value . Ival = php3_list_insert ( (void *) resource, LE_RESOURCE_TYPE) ; 

return_value->type = IS_LONG; 

Example B-8, Using an existing resource 

pval *resource_id; 
RESOURCE *resource; 
int type; 

convert_to_long (resource_id) ; 

resource = php3_list_f ind (resource_id->value . Ival, &type) ; 

if (type != LE_RESOURCE_TYPE) { 

php3_error (E_WARNING, "resource index %d has the wrong 
type" , resource_id->value . Ival) ; 

RETURN_FALSE; 
} 
/* . . .use resource. . . */ 



Example B-9, Deleting an existing resource 

pval *resource_id; 
RESOURCE ^resource; 
int type; 

convert_to_long (resource_id) ; 
php3_list_delete (resource_id->value . Ival ) ; 

The resource types should be registered in php3_list.h, in enum list_entry_type. In addition, one should add shutdown 
code for any new resource type defined, in list.c's list_entry_destructor() (even if you don't have anything to do on 
shutdown, you must add an empty case). 

Using the persistent resource table 

PHP 3.0 has a standard way of storing persistent resources (i.e., resources that are kept in between hits). The first module 
to use this feature was the MySQL module, and mSQL followed it, so one can get the general impression of how a 
persistent resource should be used by reading mysql.c. The functions you should look at are: 

php3_mysql_do_connect 

php3_mysql_connect() 

php3_mysql_pconnect() 

The general idea of persistence modules is this: 

1. Code all of your module to work with the regular resource list mentioned in section (9). 

2. Code extra connect functions that check if the resource already exists in the persistent resource list. If it does, 
register it as in the regular resource list as a pointer to the persistent resource list (because of 1., the rest of the 
code should work immediately). If it doesn't, then create it, add it to the persistent resource list AND add a pointer 
to it from the regular resource list, so all of the code would work since it's in the regular resource list, but on the 
next connect, the resource would be found in the persistent resource list and be used without having to recreate it. 
You should register these resources with a different type (e.g. LE_MYSQL_LINK for non-persistent link and 
LE_MYSQL_PLINK for a persistent link). 

If you read mysql.c, you'll notice that except for the more complex connect function, nothing in the rest of the module 
has to be changed. 

The very same interface exists for the regular resource list and the persistent resource list, only 'list' is replaced with 
'plist': 

q php3_plist_insert(ptr, type) - returns the 'id' of the newly inserted resource 

q php3_plist_delete(id) - delete the resource with the specified id 

q php3_plist_find(id,*type) - returns the pointer of the resource with the specified id, updates 'type' to the resource's 
type 

However, it's more than likely that these functions would prove to be useless for you when trying to implement a 
persistent module. Typically, one would want to use the fact that the persistent resource list is really a hash table. For 
instance, in the MySQL/mSQL modules, when there's a pconnect() call (persistent connect), the function builds a string 
out of the host/user/passwd that were passed to the function, and hashes the SQL link with this string as a key. The next 
time someone calls a pconnect() with the same host/user/passwd, the same key would be generated, and the function 
would find the SQL link in the persistent list. 

Until further documented, you should look at mysql.c or msql.c to see how one should use the plist's hash table abilities. 

One important thing to note: resources going into the persistent resource list must *NOT* be allocated with PHP's 
memory manager, i.e., they should NOT be created with emalloc(), estrdupO, etc. Rather, one should use the regular 
mallocO, strdupO, etc. The reason for this is simple - at the end of the request (end of the hit), every memory chunk that 
was allocated using PHP's memory manager is deleted. Since the persistent list isn't supposed to be erased at the end of a 
request, one mustn't use PHP's memory manager for allocating resources that go to it. 



When you register a resource that's going to be in the persistent list, you should add destructors to it both in the 
non-persistent list and in the persistent list. The destructor in the non-persistent list destructor shouldn't do anything. The 
one in the persistent list destructor should properly free any resources obtained by that type (e.g. memory, SQL links, 
etc). Just like with the non-persistent resources, you *MUST* add destructors for every resource, even it requires no 
destructotion and the destructor would be empty. Remember, since emalloc() and friends aren't to be used in conjunction 
with the persistent list, you mustn't use efree() here either. 

Adding runtime configuration directives 

Many of the features of PHP3 can be configured at runtime. These configuration directives can appear in either the 
designated php3.ini file, or in the case of the Apache module version in the Apache .conf files. The advantage of having 
them in the Apache .conf files is that they can be configured on a per-directory basis. This means that one directory may 
have a certain safemodeexecdir for example, while another directory may have another. This configuration granularity is 
especially handy when a server supports multiple virtual hosts. 

The steps required to add a new directive: 

1. Add directive to php3_ini_structure struct in mod_php3.h. 

2. In main.c, edit the php3_module_startup function and add the appropriate cfg_get_string() or cfg_get_long() call. 

3. Add the directive, restrictions and a comment to the php3_commands structure in mod_php3.c. Note the 
restrictions part. RSRC_CONF are directives that can only be present in the actual Apache .conf files. Any 
OR_OPTIONS directives can be present anywhere, include normal .htaccess files. 

4. In either php3takelhandler() or php3flaghandler() add the appropriate entry for your directive. 

5. In the configuration section of the _php3_info() function in functions/info.c you need to add your new directive. 

6. And last, you of course have to use your new directive somewhere. It will be addressable as php3_ini.directive. 

Notes 

[11 Be careful here. The value part must be malloc'ed manually because the memory 

management code will try to free this pointer later. Do not pass statically allocated memory 
into a SET_VAR_STRING. 

Prev Home Next 

Other incompatibilities Up Calling User Functions 



PHP Manual 

Prev Next 



array_values 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

array _values ~ Return all the values of an array 

Description 

array array_values(array input); 

array _values() returns all the values from the input array. 

Example 1. array_values() example 

$array = array ("size" => "XL", "color" => "gold"); 
array_values ($array) ; // returns array ("XL", "gold") 

Note: This function was added in PHP 4.0. 

Prev Home Next 

array_unshift U^ array_walk 



PHP Manual 

Prev Chapter 18. Handling file uploads Next 



Common Pitfalls 



The MAX_FILE_SIZE item cannot specify a file size greater than the file size that has been set in 
the upload_max_filesize in the PHP3.ini file or the corresponding php3_upload_max_filesize 
Apache .conf directive. The default is 2 Megabytes. 

Please note that the CERN httpd seems to strip off everything starting at the first whitespace in the 
content-type mime header it gets from the client. As long as this is the case, CERN httpd will not 
support the file upload feature. 

Prev Home Next 

Handling file uploads Ug Uploading multiple files 



PHP Manual 

Prev Next 



array_flip 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

array _flip ~ FHp all the values of an array 

Description 

array array_flip(array trans); 

array _flip() returns an array in flip order. 

Example 1. array_flip() example 

$trans = array_flip ($trans); 
$original = strtr ($str, $trans); 

Note: This function was added in PHP 4.0. 



Prev Home Next 

array_count_values U^ array_keys 



PHP Manual 

Prev Next 



array_keys 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

array _keys ~ Return all the keys of an array 

Description 

array array_keys(array input, mixed [search_value]); 

array _keys() returns the keys, numeric and string, from the input array. 

If the optional search_value is specified, then only the keys for that value are returned. 
Otherwise, all the keys from the input are returned. 

Example 1. array_keys() example 

$array = array (0 => 100, "color" => "red"); 
array_keys ($array) ; // returns array (0, "color") 

$array = array (1, 100, 2, 100); 

array_keys ($array, 100); // returns array (0, 2) 

See also array_values() . 

Note: This function was added in PHP 4.0. 

Prev Home Next 

array _flip Up array_merge 



PHP Manual 

Prev Next 



array_merge 



rhis function is not supported in the 

'HP Lite edition. 

'ossible workaround not yet published. 



3 



array _merge — Merge two or more arrays 

Description 

array array_merge(array arrayl, array array2, [ ...] ); 

array_merge() merges the elements of two or more arrays together so that the values of one are 
appended to the end of the previous one. It returns the resulting array. 

If the input arrays had the same string keys, then the later value for that key will overwrite previous one. 
If, however, the arrays have the same numeric key, this does not happen since the values are appended. 

Example 1. array _merge() example 

$arrayl = array ( "color " => "red", 2, 4); 

$array2 = array ("a", "b", "color" => "green", "shape" => "trapezoid"); 

array_merge ( $arrayl, $array2); 

Resulting array will be arrayC'color" => "green", 2, 4, "a", "b", "shape" => "trapezoid"). 
Note: This function was added in PHP 4.0. 

Prev Home Next 

array_keys Up array_pad 



PHP Manual 

Prev Next 



array_pad 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

array _pad ~ Pad array to the specified length with a value 

Description 

array array_pad(array input, int pad_size, mixed pad_value); 

array _pad() returns a copy of the input padded to size specified hy pad_size with value 
pad_value. If pad_size is positive then the array is padded on the right, if it's negative then on 
the left. If the absolute value of pad_size is less than or equal to the length of the input then no 
padding takes place. 

Example 1. array_pad() example 

$input = array (12, 10, 9); 

$result = array_pad ( $input , 5, ) ; 
// result is array(12, 10, 9, 0, 0) 

$result = array_pad ($input , -7, -1); 

// result is array(-l, -1, -1, -1, 12, 10, 9) 

$result = array_pad ( $input , 2, "noop"); 
// not padded 



Prev Home Next 

array_merge Up array_pop 



PHP Manual 

Prev Next 



array_pop 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

array _pop ~ Pop the element off the end of array 

Description 

mixed array_pop(array array); 

array _pop() pops and returns the last value of the array, shortening the ar ray hy one element. 

Example 1. array_pop() example 

$stack = array ( "orange" , "apple", "raspberry"); 
$fruit = array_pop ($stack) ; 

After this, $stack has only 2 elements: "orange" and "apple", and $fruit has "raspberry". 
See also array_push() , array_shift() , and array_unshift() . 
Note: This function was added in PHP 4.0. 

Prev Home Next 

array_pad U^ array_push 



PHP Manual 

Prev Next 



array_push 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



array_push ~ Push one or more elements onto the end of array 

Description 

int array_push(array array, mixed var, [...]); 

array _push() treats array as a stack, and pushes the passed variables onto the end of array. 
The length of array increases by the number of variables pushed. Has the same effect as: 

$array[] = $var; 

repeated for each var. 

Returns the new number of elements in the array. 

Example 1. array_push() example 

$stack = array (1, 2); 
array_push ($stack, "+", 3); 

This example would result in $stack having 4 elements: 1, 2, "+", and 3. 
See also: array_pop() , array_shift() , and array_unshift() . 
Note: This function was added in PHP 4.0. 

Prev Home Next 

array_pop U^ array_reverse 



PHP Manual 

Prev Next 



array_reverse 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



array _reverse ~ Return an array with elements in reverse order 

Description 

array array_reverse(array array); 

array _reverse() takes input array and returns a new array with the order of the elements 
reversed. 

Example 1. array_reverse() example 

$input = array ("php", 4.0, array ( "green" , "red")); 
$result = array_reverse ( $input ) ; 

This makes $resulthave array(array(" green", "red"), 4.0, "php"). 
Note: This function was added in PHP 4.0 Beta 3. 

Prev Home Next 

array_push Ug array_shift 



PHP Manual 

Prev Next 



array_shift 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

array_shift ~ Pop an element off the beginning of array 

Description 

mixed array_shift (array array); 

array _shift() shifts the first value of the array off and returns it, shortening the array by one 
element and moving everything down. 

Example 1. array_shift() example 

$args = array ("-v", "-f"); 
$opt = array_shif t ($args) ; 

This would result in $args having one element "-f" left, and $opt being "-v". 
See also array_unshift() , array_push() , and array_pop() . 
Note: This function was added in PHP 4.0. 

Prev Home Next 

array_reverse Up array_slice 



PHP Manual 

Prev Next 



array_slice 



This function is not supported in t 

PHP Lite edition. 

Possible workaround not yet published. 



ished. I 



array_slice ~ Extract a slice of the array 

Description 

array array_slice (array array, int offset, int [length] ) ; 

array_slice() returns a sequence of elements from the array specified by the offset and 
length parameters. 

If offset is positive, the sequence will start at that offset in the array. If offset is negative, 
the sequence will start that far from the end of the array. 

If length is given and is positive, then the sequence will have that many elements in it. If 
length is given and is negative then the sequence will stop that many elements from the end of 
the array. If it is omitted, then the sequence will have everything from offset up until the end of 

the array. 

Example 1. array_slice() examples 

$input = array ("a", "b", "c", "d", "e"); 



II ^ II 



11^ II 



II ^ II 



$output = array_slice ( $input , 2); // returns "c", "d", and "e 

$output = array_slice ( $input , 2, -1); // returns "c", "d 

$output = array_slice ( $input , -2, 1); // returns "d" 

$output = array_slice ( $input , 0, 3); // returns "a", "b", and "c 

See also array_splice() . 

Note: This function was added in PHP 4.0. 

Prev Home Next 

array _shift U^ array_splice 



PHP Manual 

Prev Next 



array_splice 



BHPmnction i^oouppOTBcn^m^^^H 

PHP Lite edition. H 

^fcssibl^workaroun^io^e^ublished^B 



array _splice — Remove a portion of the array and replace it with something else 

Description 

array array_splice(array input, int offset, int [length] , array [replacement]); 

array_splice() removed the elements designated by offset and length from the input array, and replaces them with 
the elements of the replacement array, if supplied. 

If offset is positive then the start of removed portion is at that offset from the beginning of the input array. If offset is 
negative then it starts that far from the end of the input array. 

If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then 
that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that 
many elements from the end of the array. Tip: to remove everything from offset to the end of the array when 

replacement is also specified, use count ($ input ) for length. 

If replacement array is specified, then the removed elements are replaced with elements from this array. If offset and 
1 ength are such that nothing is removed, then the elements from the replacement array are inserted in the place 
specified by the offset. Tip: if the replacement is just one element it is not necessary to put array ( ) around it, unless the 
element is an array itself. 

The following equivalences hold: 

array_push ($input, $x, $y) array_splice ($input, count ( $input ) , 0, array {$x, $y) ) 

array_pop ($input ) array_splice ($input, -1) 

array_shift ($input ) array_splice ($input, 0, 1) 

array_unshift ($input , $x, $y) array_splice ($input, 0, 0, array ($x, $y) ) 

$a[$x] = $y array_splice ($input, $x, 1, $y) 

Returns the array consisting of removed elements. 
Example 1. array_splice() examples 

$input = array ( "red" , "green", "blue", "yellow"); 

array_splice ( $input, 2); // $input is now array ("red", "green") 

array_splice ( $input, 1, -1); // $input is now array ("red", "yellow") 

array_splice ( $input, 1, count ($input) , "orange"); 

// $input is now array ("red", "orange") 

array_splice ( $input, -1, 1, array ( "black" , "maroon")); 

// $input is now array ("red", "green", 
// "blue", "black", "maroon") 

See also array_slice() . 

Note: This function was added in PHP 4.0. 

Prev Home Next 



array_slice Ug array_unshift 



PHP Manual 

Prev Next 



array_unshift 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



array _unshift ~ Push one or more elements onto the beginning of array 

Description 

int array_unshif t (array array, mixed var, [...]); 

array _unshift() prepends passed elements to the front of the array. Note that the list of elements 
is prepended as a whole, so that the prepended elements stay in the same order. 

Returns the new number of elements in the array. 

Example 1. array_unshift() example 

$queue = array ("pi", "p3"); 
array_unshif t ( $queue, "p4", "p5", "p6"); 

This would result in $queue having 5 elements: "p4", "p5", "p6", "pi", and "p3". 
See also array_shift() , array_push() , and array_pop() . 
Note: This function was added in PHP 4.0. 

Prev Home Next 

array_splice U^ array_values 



PHP Manual 

Prev Next 



extract 

extract ~ Import variables into the symbol table from an array 

Description 

void extract(array var_array, int [extract_type] , string [prefix] ); 

This function is used to import variables from an array into the current symbol table. It takes 
associative array var_array and treats keys as variable names and values as variable values. For 
each key/value pair it will create a variable in the current symbol table, subject to extract_type 
and prefix parameters. 

extractO checks for colissions with existing variables. The way collisions are treated is determined 
by extract_type. It can be one of the following values: 

EXTR_OVERWRITE 

If there is a collision, overwrite the existing variable. 
EXTR_SKIP 

If there is a collision, don't overwrite the existing variable. 
EXTR_PREFIX_SAME 

If there is a collision, prefix the new variable with prefix. 
EXTR_PREFIX_ALL 

Prefix all variables with prefix. 

If extract_type is not specified, it is assumed to be EXTR_OVERWRITE. 

Note that prefix is only required if extract_type is EXTR_PREFIX_SAME or 
EXTR_PREFIX_ALL. 

extractO checks each key to see if it constitues a valid variable name, and if it does only then does 
it proceed to import it. 

A possible use for extract is to import into symbol table variables contained in an associative array 
returned by wddx_deserialize() . 



Example 1. extract example 

<? 

/* Suppose that $var_array is an array returned from 

wddx_deserialize */ 
$size = "large"; 

$var_array = array ( "color" => "blue", 

"size" => "medium", 

"shape" => "sphere"); 
extract ($var_array, EXTR_PREFIX_SAME, "wddx"); 

print "$color, $size, $shape, $wddx_size\n" ; 

?> 

The above example will produce: 

blue, large, sphere, medium 

The $size wasn't overwritten, becaus we specified EXTR_PREFIX_SAME, which resulted in 
$wddx_size being created. If EXTR_SKIP was specified, then $wddx_size wouldn't even have 
been created. EXTR_OVER WRITE would have cause $size to have value "medium", and 
EXTR_PREFIX_ALL would result in new variables being named $wddx_color, $wddx_size, and 
$wddx_shape. 

Prev Home Next 

end U^ in_array 



PHP Manual 

Prev Next 



in_array 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

in_array ~ Return true if a value exists in an array 

Description 

bool in_ar ray (mixed needle, array haystack); 

Searches haystack for needle and returns true if it is found in the array, false otherwise. 

Example 1. in_array() example 

$os = array ("Mac", "NT", "Irix", "Linux"); 
if (in_array ( " Irix" , $os)) 
print "Got Irix"; 

Note: This function was added in PHP 4.0. 

Prev Home Next 

extract U^ key 



PHP Manual 

Prev Next 



aspell_new 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

aspell_new ~ load a new dictionary 

Description 

int aspell_new(string master, string personal); 

aspell_new() opens up a new dictionary and returns the dictionary link identifier for use in other 
aspell functions. 

Example 1. aspell_new 

$aspell_link=aspell_new ( "english" ) ; 

Prev Home Next 

Aspell functions Up aspell_check 



PHP Manual 

Prev Next 



aspell_check 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



aspell_check — check a word 

Description 

boolean a spell_check(int dictionary Jink, string word); 

aspell_check() checks the spelHng of a word and returns true if the spelhng is correct, false if not. 
Example 1. aspell_check 

$aspell_link=aspell_new ( "english" ) ; 

if (aspell_check ($aspell_link, "testt " ) ) { 

echo "This is a valid spelling"; 
} else { 

echo "Sorry, wrong spelling"; 
} 

Prev Home Next 

aspell_new U£ aspell_check-raw 



PHP Manual 

Prev Next 



aspell_check-raw 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



aspell_check-raw ~ check a word without changing its case or trying to trim it 

Description 

boolean a spell_check_raw(int dictionary Jink, string word); 

aspell_check_raw() checks the spelHng of a word, without changing its case or trying to trim it in 
any way and returns true if the spelHng is correct, false if not. 
Example 1. aspell_check_raw 

$aspell_link=aspell_new ( "english" ) ; 

if (aspell_check_raw ($aspell_link, "testt " ) ) { 

echo "This is a valid spelling"; 
} else { 

echo "Sorry, wrong spelling"; 
} 

Prev Home Next 

aspell_check Ug aspell_suggest 



PHP Manual 

Prev Next 



aspell_suggest 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

aspell_suggest ~ suggest spelHngs of a word 

Description 

array aspell_suggest(int dictionary_Hnk, string word); 

aspell_suggest() returns an array of possible spelHngs for the given word. 
Example 1. aspell_suggest 

$aspell_link=aspell_new ( "english" ) ; 

if ( ! aspell_check ( $aspell_link, "testt " ) ) { 

$suggestions=aspell_suggest ($aspell_link, "testt") ; 

for($i=0; $i < count ($suggestions) ; $i++) { 

echo "Possible spelling: " . $suggestions [$i] . "<br>"; 
} 



Prev Home Next 

aspell_check-raw Ug Calendar functions 



PHP Manual 

Prev Next 



hw_Array20bjrec 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Array20bjrec ~ convert attributes from object array to object record 

Description 

strin hw_array2ob jrec(array object_array); 

Converts an object_array into an object record. Multiple attributes like 'Title' in different 
languages are treated properly. 

See also h w_obj rec2ar ray () . 

Prev Home Next 

Hyperwave functions U^ hw_Children 



PHP Manual 

Prev Next 



hw_PipeDocument 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_PipeDocument ~ retrieve any document 

Description 

int hw_pipedocument(int connection, int objectID); 



Returns the Hyperwave document with object ID objectID. If the document has anchors which 
can be inserted, they will have been inserted already. The document will be transfered via a special 
data connection which does not block the control connection. 

See also hw_GetText() for more on link insertion, hw_FreeDocument(), hw_DocumentSize() , 
h w_DocumentBody TagO , hw_OutputDocument() . 

Prev Home Next 

hw_pConnect Up hw_Root 



PHP Manual 

Prev Next 



hw GetText 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetText ~ retrieve text document 

Description 

int hw_gettext(int connection, int objectID, mixed [rootlD/prefix] ); 

Returns the document with object ID objectID. If the document has anchors which can be 
inserted, they will be inserted already. The optional parameter rootlD/prefix can be a string or 
an integer. If it is an integer it determines how links are inserted into the document. The default is 
and will result in links that are constructed from the name of the link's destination object. This is 
useful for web applications. If a link points to an object with name 'internet_movie' the HTML link 
will be <A HREF="/internet_movie">. The actual location of the source and destination object in 
the document hierachy is disregarded. You will have to set up your web browser, to rewrite that 
URL to for example '/my_script.php3/internet_movie'. 'my_script.php3' will have to evaluate 
$PATH_INFO and retrieve the document. All links will have the prefix '/my_script.php3/'. If you 
do not want this you can set the optional parameter rootlD/prefix to any prefix which is used 
instead. Is this case it has to be a string. 

If rootlD/prefix is an integer and unequal to the link is constructed from all the names 
starting at the object with the id rootlD/prefix separated by a slash relative to the current 
object. If for example the above document 'internet_movie' is located at 'a-b-c-intemet_movie' with 
'-' being the seperator between hierachy levels on the Hyperwave server and the source document is 
located at 'a-b-d-source' the resulting HTML link would be: <A HREF="../c/internet_movie">. This 
is useful if you want to download the whole server content onto disk and map the document 
hierachy onto the file system. 

This function will only work for pure text documents. It will not open a special data connection and 
therefore blocks the control connection during the transfer. 

See also hw_PipeDocument() , hw_FreeDocument(), hw_DocumentBodyTag() , 
hw_DocumentSize() , h w_OutputDocument() . 

Prev Home Next 

hw_GetAndLock lj£ hw_GetObjectBy Query 



PHP Manual 

Prev Next 



hwJnsertObject 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_InsertObject ~ inserts an object record 

Description 



int hw_insert ob j ect(int connection, string object rec, string parameter); 

Inserts an object into the server. The object can be any vahd hyperwave object. See the HG-CSP 
documentation for a detailed information on how the parameters have to be. 

Note: If you want to insert an Anchor, the attribute Position has always been set either to a start/end 
value or to 'invisible'. Invisible positions are needed if the annotation has no correspondig link in 
the annotation text. 

See also hw_PipeDocument() , hw_InsertDocument() , hw_InsDoc() , hw_InsColl() . 

Prev Home Next 

hw_InsertDocument Ug hw_mapid 



PHP Manual 

Prev Next 



hw Children 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Children ~ object ids of children 

Description 

array hw_children(int connection, int objectID); 

Returns an array of object ids. Each id belongs to a child of the collection with ID objectID. The 
array contains all children both documents and collections. 

Prev Home Next 

hw_Array20bjrec Up hw_ChildrenObj 



PHP Manual 

Prev Next 



hw_ChildrenObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_ChildrenObj ~ object records of children 

Description 

array hw_childrenob j(int connection, int objectID); 

Returns an array of object records. Each object record belongs to a child of the collection with ID 
objectID. The array contains all children both documents and collections. 

Prev Home Next 

hw_Children Up hw_Close 



PHP Manual 

Prev Next 



hw Close 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Close ~ closes the Hyperwave connection 

Description 

int hw_close(int connection); 

Returns false if connection is not a valid connection index, otherwise true. Closes down the 
connection to a Hyperwave server with the given connection index. 

Prev Home Next 

hw_ChildrenObj Up hw_Connect 



PHP Manual 

Prev Next 



hw Connect 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_Connect ~ opens a connection 

Description 

int hw_connect(string host, int port, string username, string password); 

Opens a connection to a Hyperwave server and returns a connection index on success, or false if the 
connection could not be made. Each of the arguments should be a quoted string, except for the port 
number. The username and password arguments are optional and can be left out. In such a case 
no identification with the server will be done. It is similar to identify as user anonymous. This 
function returns a connection index that is needed by other Hyperwave functions. You can have 
multiple connections open at once. Keep in mind, that the password is not encrypted. 

See also hw_pConnect() . 

Prev Home Next 

hw_Close Up hw_Cp 



PHP Manual 

Prev Next 



hw_Cp 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_Cp ~ copies objects 

Description 

int hw_cp(int connection, array object_id_array, int destination id); 

Copies the objects with object ids as specified in the second parameter to the collection with the id 

destination id. 

The value return is the number of copied objects. 
See also hw_mv() . 

Prev Home Next 

hw_Connect Up hw_Deleteobject 



PHP Manual 

Prev Next 



hw_Deleteobject 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Deleteobject ~ deletes object 

Description 

int hw_deleteob ject(int connection, int object_to_delete); 

Deletes the object with the given object id in the second parameter. It will delete all instances of the 
object. 

Returns TRUE if no error occurs otherwise FALSE. 

See also hw_mv() . 

Prev Home Next 

hw_Cp Up hw_DocBy Anchor 



PHP Manual 

Prev Next 



hw_DocByAnchor 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_DocBy Anchor ~ object id object belonging to anchor 

Description 

int hw_docbyanchor(int connection, int anchorlD); 

Returns an th object id of the document to which anchorlD belongs. 

Prev Home Next 

hw_Deleteobject Up hw_DocByAnchorObj 



PHP Manual 

Prev Next 



hw_DocByAnchorObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_DocByAnchorObj ~ object record object belonging to anchor 

Description 

string hw_docbyanchorob j(int connection, int anchorlD); 
Returns an th object record of the document to which anchorlD belongs. 

Prev Home Next 

hw_DocBy Anchor Up hw_DocumentAttributes 



PHP Manual 

Prev Next 



hw_DocumentAttributes 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_DocumentAttributes ~ object record of hw_document 

Description 

string hw_documentattributes(int hw_document); 

Returns the object record of the document. 

See also hw_DocumentBodyTag() , h w_DocumentSize() . 

Prev Home Next 

hw_DocByAnchorObj U^ hw_DocumentBodyTag 



PHP Manual 

Prev Next 



hw_DocumentBodyTag 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_DocumentBodyTag ~ body tag of hw_document 

Description 

string hw_documentbodytag(int hw_document); 

Returns the BODY tag of the document. If the document is an HTML document the BODY tag 
should be printed before the document. 

See also hw_DocumentAttributes() , h w_DocumentSize() . 

Prev Home Next 

hw_DocumentAttributes Ug hw_DocumentContent 



PHP Manual 

Prev Next 



hw_DocumentContent 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_DocumentContent ~ returns content of hw_document 

Description 

string hw_documentcontent(int hw_document); 

Returns the content of the document. If the document is an HTML document the content is 
everything after the BODY tag. Information from the HEAD and BODY tag is in the stored in the 
object record. 

See also hw_DocumentAttributes() , hw_DocumentSize() , h w_DocumentSetContent() . 

Prev Home Next 

hw_DocumentBodyTag Up hw_DocumentSetContent 



PHP Manual 

Prev Next 



hw DocumentSetContent 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_DocumentSetContent ~ sets/replaces content of hw_document 

Description 

string hw_documentsetcontent(int hw_document, string content); 

Sets or replaces the content of the document. If the document is an HTML document the content is 
everything after the BODY tag. Information from the HEAD and BODY tag is in the stored in the 
object record. If you provide this information in the content of the document too, the Hyperwave 
server will change the object record accordingly when the document is inserted. Probably not a very 
good idea. If this functions fails the document will retain its old content. 

See also hw_DocumentAttributes() , hw_DocumentSize() , hw_DocumentContent() . 

Prev Home Next 

hw_DocumentContent Up hw_DocumentSize 



PHP Manual 

Prev Next 



hw_DocumentSize 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_DocumentSize ~ size of hw_document 

Description 

int hw_documentsize(int hw_document); 

Returns the size in bytes of the document. 

See also hw_DocumentBodyTag() , hw_DocumentAttributes() . 

Prev Home Next 

hw_DocumentSetContent U^ hw_ErrorMsg 



PHP Manual 

Prev Next 



hw_ErrorMsg 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_ErrorMsg ~ returns error message 

Description 

string hw_errormsg(int connection); 

Returns a string containing the last error message or 'No Error'. If false is returned, this function 
failed. The message relates to the last command. 

Prev Home Next 

hw_DocumentSize Up hw_EditText 



PHP Manual 

Prev Next 



hw EditText 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_EditText ~ retrieve text document 

Description 

int hw_edittext(int connection, int hw_document); 

Uploads the text document to the server. The object record of the document may not be modified 
while the document is edited. This function will only works for pure text documents. It will not 
open a special data connection and therefore blocks the control connection during the transfer. 

See also hw_PipeDocument() , hw_FreeDocument(), hw_DocumentBodyTag() , 
hw_DocumentSize() , h w_OutputDocument() , hw_GetText() . 

Prev Home Next 

hw_ErrorMsg Up hw_Error 



PHP Manual 

Prev Next 



hw Error 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_Error ~ error number 

Description 

int h w_err or (int connection); 

Returns the last error number. If the return value is no error has occurred. The error relates to the 
last command. 

Prev Home Next 

hw_EditText Up hw_Free_Document 



PHP Manual 

Prev Next 



hw_Free_Document 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Free_Document ~ frees hw_document 

Description 

int hw_f ree_document(int hw_document); 

Frees the memory occupied by the Hyperwave document. 



Prev Home Next 

hw_Error Up hw_GetParents 



PHP Manual 

Prev Next 



hw GetParents 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetParents ~ object ids of parents 

Description 

array hw_getparentsob j(int connection, int objectID); 

Returns an indexed array of object ids. Each object id belongs to a parent of the object with ID 

objectID. 

Prev Home Next 

hw_Free_Document Up hw_GetParentsObj 



PHP Manual 

Prev Next 



hw_GetParentsObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetParentsObj ~ object records of parents 

Description 

array hw_getparentsob j(int connection, int objectID); 

Returns an indexed array of object records plus an associated array with statistical information 
about the object records. The associated array is the last entry of the returned array. Each object 
record belongs to a parent of the object with ID objectID. 

Prev Home Next 

hw_GetParents Ug_ hw_GetChildColl 



PHP Manual 

Prev Next 



hw_GetChildColl 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetChildColl ~ object ids of child collections 

Description 

array hw_getchildcoll(int connection, int objectID); 

Returns an array of object ids. Each object ID belongs to a child collection of the collection with ID 
objectID. The function will not return child documents. 

See also hw_GetChildren(), hw_GetChildDocColl() . 

Prev Home Next 

hw_GetParentsObj Ug hw_GetChildCollObj 



PHP Manual 

Prev Next 



hw_GetChildCollObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetChildCollObj ~ object records of child collections 

Description 

array hw_getchildcollobj(int connection, int objectID); 

Returns an array of object records. Each object records belongs to a child collection of the 
collection with ID objectID. The function will not return child documents. 

See also hw_ChildrenObi() , hw_GetChildDocCollObi() . 

Prev Home Next 

hw_GetChildColl U^ hw_GetRemote 



PHP Manual 

Prev Next 



hw_GetRemote 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetRemote ~ Gets a remote document 

Description 

int hw_getremote(int connection, int objectID); 

Returns a remote document. Remote documents in Hyperwave notation are documents retrieved 
from an external source. Common remote documents are for example external web pages or queries 
in a database. In order to be able to access external sources throught remote documents Hyperwave 
introduces the HGI (Hyperwave Gateway Interface) which is similar to the CGI. Currently, only 
ftp, http-servers and some databases can be accessed by the HGI. Calling hw_GetRemote() returns 
the document from the external source. If you want to use this function you should be very familiar 
with HGIs. You should also consider to use PHP instead of Hyperwave to access external sources. 
Adding database support by a Hyperwave gateway should be more difficult than doing it in PHP. 

See also hw_GetRemoteChildren() . 

Prev Home Next 

hw_GetChildCollObj Up hw_GetRemoteChildren 



PHP Manual 

Prev Next 



hw_GetRemoteChildren 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetRemoteChildren ~ Gets children of remote document 

Description 

int hw_getremotechildren(int connection, string object record); 

Returns the children of a remote document. Children of a remote document are remote documents 
itself. This makes sense if a database query has to be narrowed and is explained in Hyperwave 
Programmers' Guide. If the number of children is 1 the function will return the document itself 
formated by the Hyperwave Gateway Interface (HGI). If the number of children is greater than 1 it 
will return an array of object record with each maybe the input value for another call to 
hw_GetRemoteChildren() . Those object records are virtual and do not exist in the Hyperwave 
server, therefore they do not have a valid object ID. How exactely such an object record looks like 
is up to the HGI. If you want to use this function you should be very familiar with HGIs. You 
should also consider to use PHP instead of Hyperwave to access external sources. Adding database 
support by a Hyperwave gateway should be more difficult than doing it in PHP. 

See also hw_GetRemote() . 

Prev Home Next 

hw_GetRemote U^ hw_GetSrcByDestObj 



PHP Manual 

Prev Next 



hw_GetSrcByDestObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetSrcByDestObj ~ Returns anchors pointing at object 

Description 

array hw_getsrcbydestob j(int connection, int objectID); 

Returns the object records of all anchors pointing to the object with ID objectID. The object can 
either be a document or an anchor of type destination. 

See also hw_GetAnchors() . 

Prev Home Next 

hw_GetRemoteChildren Ug hw_GetObject 



PHP Manual 

Prev Next 



hw_GetObject 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetObject ~ object record 

Description 

array hw_getob ject(int connection, [intlarray] objectID, string query); 

Returns the object record for the object with ID objectlDif the second parameter is an integer. If 
the second parameter is an array of integer the function will return an array of object records. In 
such a case the last parameter is also evaluated which is a query string. 

The query string has the following syntax: 

<expr>::="("<expr>")"l 

"!"<expr>l/*NOT*/ 

<expr> "II" <expr> I /* OR */ 

<expr> "&&" <expr> I /* AND */ 

<attribute> <operator> <value> 

<attribute> ::= /* any attribute name (Title, Author, DocumentType ...)*/ 

<operator> ::= "=" I /* equal */ 

"<" I /* less than (string compare) */ 

">" I /* greater than (string compare) */ 

"~" /* regular expression matching */ 

The query allows to further select certain objects from the list of given objects. Unlike the other 
query functions, this query may use not indexed attributes. How many object records are returned 
depends on the query and if access to the object is allowed. 

See also hw_GetAndLock(), hw_GetObjectByQuery(). 



Prev Home Next 

hw_GetSrcByDestObj U^ hw_GetAndLock 



PHP Manual 

Prev Next 



hw GetAndLock 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetAndLock ~ return bject record and lock object 

Description 

string hw_getandlock(int connection, int objectID); 

Returns the object record for the object with ID objectID. It will also lock the object, so other 
users cannot access it until it is unlocked. 

See also hw_Unlock() , hw_GetObject() . 

Prev Home Next 

hw_GetObject U^ hw_GetText 



PHP Manual 

Prev Next 



hw_GetObjectByQuery 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetObjectBy Query ~ search object 

Description 

array hw_getob jectbyquery(int connection, string query, int max_hits); 

Searches for objects on the whole server and returns an array of object ids. The maximum number 
of matches is Hmited to max_hit s. If max_hit s is set to -1 the maximum number of matches is 
unHmited. 

The query will only work with indexed attributes. 

See also hw_GetObjectByQueryObj() . 

Prev Home Next 

hw_GetText U^ hw_GetObjectByQueryObj 



PHP Manual 

Prev Next 



hw_GetObjectByQueryObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetObjectBy Query Obj ~ search object 

Description 

array hw_getob je ctby query obj (int connection, string query, int max_hits); 

Searches for objects on the whole server and returns an array of object records. The maximum 
number of matches is Hmited to max_hits. If max_hits is set to -1 the maximum number of 
matches is unHmited. 

The query will only work with indexed attributes. 

See also hw_GetObjectByQuery() . 

Prev Home Next 

hw_GetObjectBy Query Ug hw_GetObjectByQueryColl 



PHP Manual 

Prev Next 



hw_GetObjectByQueryColl 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetObjectBy Query Coll ~ search object in collection 

Description 

array hw_getob jectbyquerycoll(int connection, int objectID, string query, int 
max_hits); 

Searches for objects in collection with ID objectID and returns an array of object ids. The 
maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum 
number of matches is unlimited. 

The query will only work with indexed attributes. 

See also hw_GetObiectByQueryCollObi() . 

Prev Home Next 

hw_GetObjectByQueryObj Ug_ hw_GetObjectByQueryCollObj 



PHP Manual 

Prev Next 



hw_GetObjectByQueryCollObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetObjectBy Query CollObj ~ search object in collection 

Description 

array hw_getob jectbyquerycollob j(int connection, int objectID, string query, int 
max_hits); 

Searches for objects in collection with ID objectID and returns an array of object records. The 
maximum number of matches is limited to max_hits. If max_hits is set to -1 the maximum 
number of matches is unlimited. 

The query will only work with indexed attributes. 

See also hw_GetObjectBy Query C ollQ . 

Prev Home Next 

hw_GetObjectByQueryColl Up hw_GetChildDocColl 



PHP Manual 

Prev Next 



hw_GetChildDocColl 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetChildDocColl ~ object ids of child documents of collection 

Description 

array hw_getchilddoccoll(int connection, int objectID); 
Returns array of object ids for child documents of a collection. 
See also hw_GetChildren(), hw_GetChildColl() . 

Prev Home Next 

hw_GetObjectBy Query CollObj UE hw_GetChildDocCollObj 



PHP Manual 

Prev Next 



hw_GetChildDocCollObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetChildDocCollObj ~ object records of child documents of collection 

Description 

array hw_getchilddoccollobj(int connection, int objectID); 
Returns an array of object records for child documents of a collection. 
See also hw_ChildrenObi() , hw_GetChildCollObi() . 

Prev Home Next 

hw_GetChildDocColl Ug_ hw_GetAnchors 



PHP Manual 

Prev Next 



hw_GetAnchors 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetAnchors ~ object ids of anchors of document 

Description 

array hw_getanchors(int connection, int objectID); 

Returns an array of object ids with anchors of the document with object ID objectID. 

Prev Home Next 

hw_GetChildDocCollObj Up hw_GetAnchorsObj 



PHP Manual 

Prev Next 



hw_GetAnchorsObj 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_GetAnchorsObj ~ object records of anchors of document 

Description 

array hw_getanchorsob j(int connection, int objectID); 

Returns an array of object records with anchors of the document with object ID objectID. 

Prev Home Next 

hw_GetAnchors Up hw_Mv 



PHP Manual 

Prev Next 



hw Mv 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_Mv ~ moves objects 

Description 

int hw_mv(int connection, array object id array, int source id, int destination id); 

Moves the objects with object ids as specified in the second parameter from the collection with id 
source id to the collection with the id destination id. If the destination id is the objects 
will be unlinked from the source collection. If this is the last instance of that object it will be 
deleted. If you want to delete all instances at once, use hw_deleteobj ect() . 

The value return is the number of moved objects. 
See also hw_cp() , hw_deleteobject() . 

Prev Home Next 

hw_GetAnchorsObj Up hw_Identify 



PHP Manual 

Prev Next 



hwjdentify 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hwjdentify ~ identifies as user 

Description 

int hw_identif y(string username, string password); 

Identifies as user with username and password. Identification is only vahd for the current 
session. I do not thing this function will be needed very often. In most cases it will be easier to 
identify with the opening of the connection. 

See also hw_Connect() . 

Prev Home Next 

hw_Mv Up hw_InCollections 



PHP Manual 

Prev Next 



hwJnCollections 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_InCollections ~ check if object ids in collections 

Description 



array hw_incollections(int connection, array object_id_array, array collection_id_array, 
int return_collections); 

Checks whether a set of objects (documents or collections) specified by the object_id_array 
is part of the collections listed in collect ion_id_ar ray. When the fourth parameter 
return_col lections is 0, the subset of object ids that is part of the collections (i.e., the 
documents or collections that are children of one or more collections of collection ids or their 
subcollections, recursively) is returned as an array. When the fourth parameter is 1, however, the 
set of collections that have one or more objects of this subset as children are returned as an array. 
This option allows a client to, e.g., highlight the part of the collection hierarchy that contains the 
matches of a previous query, in a graphical overview. 

Prev Home Next 

hw_Identify Up hw_Info 



PHP Manual 

Prev Next 



hw Info 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Info ~ info about connection 

Description 

string hw_info(int connection); 

Returns information about the current connection. The returned string has the following format: 
<Serverstring>, <Host>, <Port>, <Username>, <Port of Client>, <Byte swapping> 

Prev Home Next 

hw_InCollections Up hw_InsColl 



PHP Manual 

Prev Next 



hw InsColl 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_InsColl ~ insert collection 

Description 

int hw_inscoll(int connection, int objectID, array object_array); 

Inserts a new collection with attributes as in object_array into collection with object ID 

objectID. 

Prev Home Next 

hw_Info Up hw_InsDoc 



PHP Manual 

Prev Next 



hw InsDoc 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_InsDoc ~ insert document 

Description 

int hw_insdoc(int connection, int parentID, string object_record, string text); 

Inserts a new document with attributes as in object_record into collection with object ID 
parentID. This function inserts either an object record only or an object record and a pure ascii 
text in text if text is given. If you want to insert a general document of any kind use 
hw_insertdocument() instead. 

See also hw_InsertDocument() , hw_InsColl() . 

Prev Home Next 

hw_InsColl Up hw_InsertDocument 



PHP Manual 

Prev Next 



hw InsertDocument 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_InsertDocument ~ upload any document 

Description 

int hw_insertdocument(int connection, int parent_id, int hw_document); 

Uploads a document into the collection with parent_id. The document has to be created before 
with hw_NewDocument(). Make sure that the object record of the new document contains at least 
the attributes: Type, DocumentType, Title and Name. Possibly you also want to set the MimeType. 
The functions returns the object id of the new document or false. 

See also h w_PipeDocument() . 

Prev Home Next 

hw_InsDoc Up hw_InsertObject 



PHP Manual 

Prev Next 



hw_mapid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_mapid ~ Maps global id on virtual local id 

Description 

int hw_mapid(int connection, int server id, int object id); 

Maps a global object id on any hyperwave server, even those you did not connect to with 
hw_connect() , onto a virtual object id. This virtual object id can then be used as any other object 
id, e.g. to obtain the object record with hw_getobject() . The server id is the first part of the global 
object id (GOid) of the object which is actually the IP number as an integer. 

Note: In order to use this function you will have to set the F_DISTRIBUTED flag, which can 
currently only be set at compile time in hg_comm.c. It is not set by default. Read the comment at 
the beginning of hg_comm.c 

Prev Home Next 

hw_InsertObject Up hw_Modify object 



PHP Manual 

Prev Next 



hw_Mod if y object 

Ehis function is not supported in the^^f 
HP Lite edition. ~^H 

ossible workaround not yet publis^^H 

hw_Modifyobject — modifies object record 

Description 



int hw_modif yob ject(int connection, int object_to_change, array remove, array add, int mode); 

This command allows to remove, add, or modify individual attributes of an object record. The object is specified by 
the Object ID ohject_to_change. The first array remove is a list of attributes to remove. The second array 
add is a list of attributes to add. In order to modify an attribute one will have to remove the old one and add a new 
one. hw_modifyobject() will always remove the attributes before it adds attributes unless the value of the attribute 
to remove is not a string or array. 

The last parameter determines if the modification is performed recursively. 1 means recurive modification. If some 
of the objects cannot be modified they will be skiped without notice. hw_error() may not indicate an error though 
some of the objects could not be modified. 

The keys of both arrays are the attributes name. The value of each array element can either be an array, a string or 
anything else. If it is an array each attribute value is constructed by the key of each element plus a colon and the 
value of each element. If it is a string it is taken as the attribute value. An empty string will result in a complete 
removal of that attribute. If the value is neither a string nor an array but something else, e.g. an integer, no operation 
at all will be performed on the attribute. This is neccessary if you want to to add a completely new attribute not just 
a new value for an existing attribute. If the remove array contained an empty string for that attribute, the attribute 
would be tried to be removed which would fail since it doesn't exist. The following addition of a new value for that 
attribute would also fail. Setting the value for that attribute to e.g. would not even try to remove it and the addition 
will work. 

If you would like to change the attribute 'Name' with the current value 'books' into 'articles' you will have to create 
two arrays and call hw_inodifyobject(). 

Example 1. modifying an attribute 

// $connect is an existing connection to the Hyperwave server 

// $objid is the ID of the object to modify 

$remarr = array ( "Name" => "books"); 

$addarr = array ("Name" => "articles"); 

$hw_modif yob ject ($connect , $objid, $remarr, $addarr) ; 

In order to delete/add a name=value pair from/to the object record just pass the remove/add array and set the 
last/third parameter to an empty array. If the attribute is the first one with that name to add, set attribute value in the 
remove array to an integer. 



Example 2. adding a completely new attribute 

// $connect is an existing connection to the Hyperwave server 

// $objid is the ID of the object to modify 

$remarr = array ("Name" => 0); 

$addarr = array ("Name" => "articles"); 

$hw_modif yob ject ($connect , $objid, $remarr, $addarr) ; 

Note: Multilingual attributes, e.g. 'Title', can be modified in two ways. Either by providing the 
attributes value in its native form 'language': 'title' or by providing an array with elements for each 
language as described above. The above example would than be: 

Example 3. modifying Title attribute 

$remarr = array ( "Title" => "en :Books" ) ; 
$addarr = array ( "Title" => "en : Articles" ) ; 
$hw_modifyob ject ($connect , $objid, $remarr, $addarr) ; 

or 

Example 4. modifying Title attribute 

$remarr = array ( "Title" => array ("en" => "Books")); 

$addarr = array ( "Title" => array ("en" => "Articles", "ge"=>"Artikel" ; 

$hw_modif yob ject ($connect, $objid, $remarr, $addarr) ; 

This removes the english title 'Books' and adds the english title 'Articles' and the german title 'Artikel'. 

Example 5. removing attribute 

$remarr = array ( "Title" => ""); 

$addarr = array ( "Title" => "en : Articles" ) ; 

$hw_modif yob ject ($connect, $objid, $remarr, $addarr) ; 

Note: This will remove all attributes with the name 'Title' and adds a new 'Title' attribute. This comes in 
handy if you want to remove attributes recursively. 

Note: If you need to delete all attributes with a certain name you will have to pass an empty string as 
the attribute value. 

Note: Only the attributes 'Title', 'Description' and 'Keyword' will properly handle the language prefix. If 
those attributes don't carry a language prefix, the prefix 'xx' will be assigned. 

Note: The 'Name' attribute is somewhat special. In some cases it cannot be complete removed. You will 
get an error message 'Change of base attribute' (not clear when this happens). Therefore you will always 
have to add a new Name first and than remove the old one. 

Note: You may not suround this function by calls to hw_getandlock() and hw_unlock() . 
hw_modifyobject() does this internally. 

Returns TRUE if no error occurs otherwise FALSE. 

Prev Home Next 

hw_mapid Up hw_New_Document 



PHP Manual 

Prev Next 



hw_New_Docu merit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_New_Document ~ create new document 

Description 



int hw_new_document (string object_record, string document_data, int document_size); 

Returns a new Hyperwave document with document data set to document_data and object 
record set to object_record. The length of the document_data has to passed in 
do cument_s 1 z eThis function does not insert the document into the Hyperwave server. 

See also hw_FreeDocument(), hw_DocumentSize() , hw_DocumentBodyTag() , 
hw_OutputDocument() , hw_InsertDocument() . 

Prev Home Next 

hw_Modify object Up hw_0bjrec2Array 



PHP Manual 

Prev Next 



hw_0bjrec2 Array 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_0bjrec2Array ~ convert attributes from object record to object array 

Description 

array hw_ob jrec2array(string object_record); 

Converts an object_record into an object array. The keys of the resulting array are the 
attributes names. Multiple attributes like 'Title' in different languages form its own array. The keys 
of this array are the left part to the colon of the attribute value. Currently only the attributes 'Title', 
'Description' and 'Keyword' are treated properly. Other multiple attributes form an index array. 
Currently only the attribute 'Group' is handled properly. 

See also hw_array2objrec() . 

Prev Home Next 

hw_New_Document Up hw_OutputDocument 



PHP Manual 

Prev Next 



hw_OutputDocument 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_OutputDocument ~ prints hw_document 

Description 



int hw_outputdocument(int hw_document); 
Prints the document without the BODY tag. 



Prev Home Next 

hw_0bjrec2Array Up hw_pConnect 



PHP Manual 

Prev Next 



hw_pConnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_pConnect ~ make a persistent database connection 

Description 

int hw_p connect (string host, int port, string username, string password); 

Returns a connection index on success, or false if the connection could not be made. Opens a 
persistent connection to a Hyperwave server. Each of the arguments should be a quoted string, 
except for the port number. The username and password arguments are optional and can be left 
out. In such a case no identification with the server will be done. It is similar to identify as user 
anonymous. This function returns a connection index that is needed by other Hyperwave functions. 
You can have multiple persistent connections open at once. 

See also hw_Connect() . 

Prev Home Next 

hw_OutputDocument Up hw_PipeDocument 



PHP Manual 

Prev Next 



hw Root 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_Root ~ root object id 

Description 

int hw_root(); 

Returns the object ID of the hyperroot collection. Currently this is always 0. The child collection of 
the hyperroot is the root collection of the connected server. 

Prev Home Next 

hw_PipeDocument Up hw_Unlock 



PHP Manual 

Prev Next 



hw Unlock 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



hw_Unlock — unlock object 

Description 

int hw_unlock(int connection, int objectID); 
Unlocks a document, so other users regain access. 
See also h w_Get AndLockQ . 

Prev Home Next 

hw_Root U^ hw_Who 



PHP Manual 

Prev Next 



hw Who 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Who ~ List of currently logged in users 

Description 

int hw_who(int connection); 

Returns an array of users currently logged into the Hyperwave server. Each entry in this array is an 
array itself containing the elements id, name, system, onSinceDate, onSinceTime, TotalTime and 
self, 'self is 1 if this entry belongs to the user who initianted the request. 

Prev Home Next 

hw_Unlock U^ hw_Username 



PHP Manual 

Prev Next 



hw_Username 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

hw_Username ~ name of currently logged in user 

Description 

string hw_getusername(int connection); 
Returns the username of the connection. 



Prev Home Next 

hw_Who Up Image functions 



PHP Manual 

Prev Next 



strftime 

strftime ~ format a local time/date according to locale settings 

Description 

string strf time(string format, int timestamp); 

Returns a string formatted according to the given format string using the given timestamp or the 
current local time if no timestamp is given. Month and weekday names and other language 
dependent strings respect the current locale set with setlocaleQ . 

The following conversion specifiers are recognized in the format string: 

q %a - abbreviated weekday name according to the current locale 

q %A - full weekday name according to the current locale 

q %b - abbreviated month name according to the current locale 

q %B - full month name according to the current locale 

q %c - preferred date and time representation for the current locale 

q %d - day of the month as a decimal number (range 00 to 3 1) 

q %H - hour as a decimal number using a 24-hour clock (range 00 to 23) 

q %I - hour as a decimal number using a 12-hour clock (range 01 to 12) 

q % j - day of the year as a decimal number (range 001 to 366) 

q %m - month as a decimal number (range 1 to 12) 

q %M - minute as a decimal number 

q %p - either ^am' or ^pm' according to the given time value, or the corresponding strings for 
the current locale 

q %S - second as a decimal number 

q %U - week number of the current year as a decimal number, starting with the first Sunday as 
the first day of the first week 

q % W - week number of the current year as a decimal number, starting with the first Monday 
as the first day of the first week 

q %w - day of the week as a decimal, Sunday being 



q %x - preferred date representation for the current locale without the time 

q %X - preferred time representation for the current locale without the date 

q %y - year as a decimal number without a century (range 00 to 99) 

q %Y - year as a decimal number including the century 

q %Z - time zone or name or abbreviation 

q %% - a literal ^ %' character 

Example 1. strftime() example 

setlocale ("LC_TIME", "C"); 
print (strf time ( "%A in Finnish is ")); 
setlocale ("LC_TIME", "fi_FI"); 
print (strf time ( "%A, in French ")); 
setlocale ("LC_TIME", "fr_CA"); 
print (strf time ( "%A and in German ")); 
setlocale ("LC_TIME", "de_DE"); 
print (strftime ( "%A. \n" ) ) ; 

This example works if you have the respective locales installed in your system. 
See also setlocaleQ and mktimeQ . 

Prev Home Next 

mktime Ug time 



PHP Manual 

Prev Next 



microtime 

microtime ~ return current UNIX timestamp with microseconds 

Description 

string microtime(void); 

Returns the string "msec sec" where sec is the current time measured in the number of seconds 
since the Unix Epoch (0:00:00 January 1, 1970 GMT), and msec is the microseconds part. This 
function is only available on operating systems that support the gettimeofdayO system call. 

See also timeQ . 

Prev Home Next 

gmstrftime Ug mktime 



PHP Manual 

Prev Next 



mhash 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mhash — Compute hash 

Description 

string mhash(int hash, string data); 

mhashO apphes a hash function specified by hash to the data and returns the resulting hash 
(also called digest). 

Prev Home Next 

mhash_count Up HTTP functions 



PHP Manual 

Prev Next 



explode 

explode ~ Split a string by string 

Description 



array explode (string separator, string string); 

Returns an array of strings containing the elements separated by separator. 

Example 1. explode() example 

$pizza = "piecel piece2 pieceS piece4 pieceS piece6"; 
$pieces = explode (" ", $pizza) ; 

See also splitQ and implodeQ . 

Prev Home Next 

echo Up flush 



PHP Manual 

Prev Next 



implode 

implode ~ Join array elements with a string 

Description 

string imp lode (string glue, array pieces); 

Returns a string containing a string representation of all the array elements in the same order, with 
the glue string between each element. 

Example 1. implode() example 

$colon_separated = implode (":" , $array) ; 

See also explodeQ , joinQ , and splitQ . 

Prev Home Next 

htmlspecialchars Up join 



Prev 



PHP Manual 

Appendix C. The PHP Debugger 



Debugger Protocol 



The debugger protocol is Hne-based. Each Hne has a type, and several lines compose a message. 
Each message starts with a line of the type start and terminates with a line of the type end. PHP 
may send lines for different messages simultaneously. 

A line has this format: 

date time host(pid) type: message-data 
date 



time 



host 



pid 



type 



Date in ISO 8601 format (yyyy-mm-dd) 

Time including microseconds: hh:mm:uuuuuu 

DNS name or IP address of the host where the script error was generated. 

PID (process id) on host of the process with the PHP script that generated this error. 

Type of line. Tells the receiving program about what it should treat the following data as: 
Table C-1. Debugger Line Types 



Name 


Meaning 


start 


Tells the receiving program that a debugger message starts here. The contents 
of da t a will be the type of error message, listed below. 


message 


The PHP error message. 


location 


File name and line number where the error occured. The first location line 
will always contain the top-level location, data will contain file: line. 
There will always be a location line after message and after every 

function. 


frames 


Number of frames in the following stack dump. If there are four frames, expect 
information about four levels of called functions. If no "frames" line is given, 
the depth should be assumed to be (the error occured at top-level). 


function 


Name of function where the error occured. Will be repeated once for every 
level in the function call stack. 


end 


Tells the receiving program that a debugger message ends here. 



data 



Line data. 
Table C-2. Debugger Error Types 



Debugger 


PHP Internal 


warning 


E_WARNING 


error 


E_ERROR 


parse 


E_PARSE 


notice 


E_NOTICE 


core-error 


E_CORE_ERROR 


core-warning 


E_CORE_WARNING 


unknown 


(any other) 


Example C-1. 


Example Debugger M 



1998-04-05 23:27:400966 lucifer.guardian.no(20481) start: notice 

1998-04-05 23:27:400966 lucifer.guardian.no(20481) message: Uninitialized variable 

1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: (null):7 

1998-04-05 23:27:400966 lucifer.guardian.no(20481) frames: 1 

1998-04-05 23:27:400966 lucifer.guardian.no(20481) function: display 

1998-04-05 23:27:400966 lucifer.guardian.no(20481) location: /home/ssb/public_html/test.php3:10 

1998-04-05 23:27:400966 lucifer.guardian.no(20481) end: notice 



Prev 

The PHP Debugger 



Home 
UE 



PHP Manual 

Prev Next 



print 

print ~ Output a string 

Description 

print (string arg); 

Outputs arg. 

See also: echoQ printfQ flushQ 

Prev Home Next 

parse_str Up printf 



PHP Manual 

Prev Next 



quoted_printable_decode 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



quoted_printable_decode ~ Convert a quoted-printable string to an 8 bit string 

Description 

string quoted_printable_decode (string str); 

This function returns an 8-bit binary string corresponding to the decoded quoted printable string. 
This function is similar to imap_qprint() , except this one does not require the IMAP module to 
work. 

Prev Home Next 

printf Up QuoteMeta 



PHP Manual 

Prev Next 



sprintf 

sprintf ~ Return a formatted string 

Description 



string sprintf (string format, mixed [args]... ); 

Returns a string produced according to the formatting string format. 

The format string is composed by zero or more directives: ordinary characters (excluding %) that 
are copied directly to the result, and conversion specifications, each of which results in fetching its 
own parameter. This applies to both sprintf() and printfQ . 

Each conversion specification consists of these elements, in order: 

1 . An optional padding specifier that says what character will be used for padding the results to 
the right string size. This may be a space character or a (zero character). The default is to 
pad with spaces. An alternate padding character can be specified by prefixing it with a single 
quote ( ' ). See the examples below. 

2. An optional alignment specifier that says if the result should be left-justified or 
right-justified. The default is right-justified; a - character here will make it left-justified. 

3. An optional number, a width specifier that says how many characters (minimum) this 
conversion should result in. 

4. An optional precision specifier that says how many decimal digits should be displayed for 
floating-point numbers. This option has no effect for other types than double. (Another 
function useful for formatting numbers is number_f ormatQ . ) 

5. A type specifier that says what type the argument data should be treated as. Possible types: 

% - a literal percent character. No argument is required. 

b - the argument is treated as an integer, and presented as a binary number. 

c - the argument is treated as an integer, and presented as the character with that ASCII 

value. 

d - the argument is treated as an integer, and presented as a decimal number. 

f - the argument is treated as a double, and presented as a floating-point number. 

o - the argument is treated as an integer, and presented as an octal number. 

s - the argument is treated as and presented as a string. 

X - the argument is treated as an integer and presented as a hexadecimal number (with 

lowercase letters). 



X - the argument is treated as an integer and presented as a hexadecimal number (with 
uppercase letters). 

See also: printfQ and number_format() . 

Examples 

Example 1. sprintf: zero-padded integers 

$isodate = sprintf ( "%04d-%02d-%02d" , $year, $month, $day) ; 
Example 2. sprintf: formatting currency 

$moneyl = 68.75; 

$money2 = 54 . 35; 

$money = $moneyl + $money2; 

// echo $money will output "123.1"; 

$formatted = sprintf ("%01.2f", $money) ; 

// echo $formatted will output "123.10" 

Prev Home Next 

soundex Ug strcasecmp 



PHP Manual 

Prev Next 



flush 

flush ~ Flush the output buffer 

Description 

void flush(void); 

Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a web server, etc.) 
This effectively tries to push all the output so far to the user's browser. 

Prev Home Next 

explode Up get_html_translation_table 



PHP Manual 

Prev Appendix A. Migrating from PHP/FI 2.0 to PHP 3.0 Next 



Other incompatibilities 



q The PHP 3.0 Apache module no longer supports Apache versions prior to 1.2. Apache 1.2 or 
later is required. 

q echoQ no longer supports a format string. Use the printfQ function instead. 

q In PHP/FI 2.0, an implementation side-effect caused $ f oo [ ] to have the same effect as 
$ f oo. This is not true for PHP 3.0. 

q Reading arrays with $ array [ ] is no longer supported 

That is, you cannot traverse an array by having a loop that does $data = $array [ ] . Use 
currentQ and nextQ instead. 

Also, $arrayl [ ] = $array2 does not append the values of $array2 to $arrayl, 
but appends $ array 2 as the last entry of$arrayl. See also multidimensional array 
support. 

q " + " is no longer overloaded as a concatenation operator for strings, instead it converts it's 
arguments to numbers and performs numeric addition. Use " . " instead. 

Example A-11. Migration from 2.0: concatenation for strings 

echo "1" + "1"; 

In PHP 2.0 this would echo 1 1, in PHP 3.0 it would echo 2. Instead use: 

echo "1"."1"; 

$a = 1; 
$b = 1; 
echo $a + $b; 

This would echo 2 in both PHP 2.0 and 3.0. 

$a = 1; 
$b = 1; 
echo $a . $b; 

This will echo 1 1 in PHP 3.0. 

Prev Home Next 

Function true/false return values Up PHP development 



PHP Manual 

Prev Next 



pfsockopen 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



pfsockopen ~ Open persistent Internet or Unix domain socket connection. 

Description 

int pf sockopen(string hostname, int port, int [errno], string [errstr], int [timeout]); 

This function behaves exactly as fsockopenQ with the difference that the connection is not closed 
after the script finishes. It is the persistent version of fsockopenQ . 

Prev Home Next 

openlog Up set_socket_blocking 



PHP Manual 

Prev Next 



yp_get_def au lt_domai n 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

yp_get_default_domain ~ Fetches the machine's default NIS domain. 

Description 

int yp_get_def ault_domain(void ); 

yp_get_default_domain() returns the default domain of the node or FALSE. Can be used as the 
domain parameter for successive NIS calls. 

A NIS domain can be described a group of NIS maps. Every host that needs to look up information 
binds itself to a certain domain. Refer to the documents mentioned at the beginning for more 
detailed information. 

Example 1. Example for the default domain 

<?php 

$domain = yp_get_def ault_domain ( ) ; 

if ( ! $domain) { 

echo yp_errno() . ": " . yp_err_string ( ) ; 
} 

echo "Default NIS domain is: " . $domain; 
?> 



See also: yp_errno and yp_err_string 

Prev Home Next 

NIS functions Up yp_order 



PHP Manual 

Prev Next 



yp_order 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

yp_order ~ Returns the order number for a map. 

Description 

int yp_order(string domain, string map); 

yp_order() returns the order number for a map or FALSE. 

Example 1. Example for the NIS order 

<?php 

$number = yp_order ($domain, $mapname) ; 

if ( ! $number ) { 

echo yp_errno() . ": " . yp_err_string ( ) ; 
} 

echo "Order number for this map is: " . $order; 
?> 

See also: vp_get_default_domain vp_errno and vp_err_string 

Prev Home Next 

yp_get_default_domain U^ yp_master 



PHP Manual 

Prev Next 



yp_master 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



yp_master ~ Returns the machine name of the master NIS server for a map. 

Description 

string yp_master(string domain, string map); 

yp_master() returns the machine name of the master NIS server for a map. 

Example 1. Example for the NIS master 

<?php 

$number = yp_master ( $domain, $mapname) ; 

if ( ! $number ) { 

echo yp_errno() . ": " . yp_err_string ( ) ; 
} 

echo "Master for this map is: " . $master; 
?> 

See also: vp_get_default_domain vp_errno and vp_err_string 

Prev Home Next 

yp_order U^ yp_match 



PHP Manual 

Prev Next 



yp_match 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

yp_match ~ Returns the matched Hne. 

Description 

string yp_match(string domain, string map, string key); 

yp_match() returns the value associated with the passed key out of the specified map or FALSE. 
This key must be exact. 

Example 1. Example for NIS match 

<?php 

$entry = yp_match ($ domain, "passwd. byname" , "joe"); 

if(!$entry) { 

echo yp_errno() . ": " . yp_err_string ( ) ; 
} 

echo "Matched entry is: " . $entry; 
?> 

In this case this could be: joe:##joe: 11111: 100: Joe User:/home/j/joe:/usr/local/bin/bash 
See also: vp_get_default_domain vp_errno and vp_err_string 

Prev Home Next 

yp_master Up yp_first 



PHP Manual 

Prev Next 



yp_first 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



yp_first ~ Returns the first key-value pair from the named map. 

Description 

s t r i n g [ ] y p_f i r s t (string domain, string map) ; 

yp_first() returns the first key-value pair from the named map in the named domain, otherwise 
FALSE. 

Example 1. Example for the NIS first 

<?php 

$entry = yp_f irst ( $domain, "passwd. byname" ) ; 

if(!$entry) { 

echo yp_errno() . ": " . yp_err_string ( ) ; 
} 

$key = key($entry); 

echo "First entry in this map has key " . $key 
. " and value " . $entry [$key] ; 
?> 

See also: vp_get_default_domain vp_errno and vp_err_string 

Prev Home Next 

yp_match U^ yp_next 



PHP Manual 

Prev Next 



yp_next 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

yp_next ~ Returns the next key- value pair in the named map. 

Description 

string [ ] yp_next (string domain, string map, string key); 

yp_next() returns the next key- value pair in the named map after the specified key or FALSE. 

Example 1. Example for NIS next 

<?php 

$entry = yp_next ($ domain, "passwd. byname" , "joe"); 

if(!$entry) { 

echo yp_errno() . ": " . yp_err_string ( ) ; 
} 

$key = key($entry); 

echo "The next entry after joe has key " . $key 
. " and value " . $entry [$key] ; 
?> 

See also: vp_get_default_domain , vp_ermo and vp_err_string 

Prev Home Next 

yp_first Ug yp_errno 



PHP Manual 

Prev Next 



mysql_tablename 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_tablename ~ Get table name of field 

Description 

string my sql_tablename(int result, inti); 

mysql_tablename() takes a result pointer returned by the mysql_list_tables() function as well as 
an integer index and returns the name of a table. The mysql_num_rows() function may be used to 
determine the number of tables in the result pointer. 
Example 1. mysql_tablename() example 

<?php 

mysql_connect ( "localhost : 3306" ) ; 

$result = mysql_list_tables ("Wisconsin"); 

$i = 0; 

while ($i < mysql_num_rows ($result)) { 

$tb_names [ $i] = mysql_tablename ($result, $i); 

echo $tb_names [$i] . "<BR>"; 

$i++; 
} 
?> 

Prev Home Next 

mysql_select_db Up Network functions 



PHP Manual 

Prev Next 



checkdnsrr 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



checkdnsrr ~ Check DNS records corresponding to a given Internet host name or IP address. 

Description 

int checkdnsrr(string host, string [type]); 

Searches DNS for records of type type corresponding to host. Returns true if any records are 
found; returns false if no records were found or if an error occurred. 

type may be any one of: A, MX, NS, SOA, PTR, CNAME, or ANY. The default is MX. 

host may either be the IP address in dotted-quad notation or the host name. 

See also getmxrrQ , gethostbyaddrQ , gethostbynameQ , gethostbynamelQ , and the named(8) 
manual page. 

Prev Home Next 

Network functions Up closelog 



PHP Manual 

Prev Next 



closelog 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

closelog ~ close connection to system logger 

Description 

int closelog(void); 

closelogO closes the descriptor being used to write to the system logger. The use of closelogO is 
optional. 

Prev Home Next 

checkdnsrr Up debugger_off 



PHP Manual 

Prev Next 



debugger_off 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

debugger_off ~ disable internal PHP debugger 

Description 

int debugger_of f (void); 

Disables the internal PHP debugger. The debugger is still under development. 

Prev Home Next 

closelog Up debugger_on 



PHP Manual 

Prev Next 



debugger_on 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

debugger_on ~ enable internal PHP debugger 

Description 

int debugger_on(string address); 

Enables the internal PHP debugger, connecting it to address. The debugger is still under 
development. 

Prev Home Next 

debugger_off Up fsockopen 



PHP Manual 

Prev Next 



gethostbyaddr 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gethostbyaddr — Get the Internet host name corresponding to a given IP address. 

Description 

string gethostbyaddr(string ip_address); 

Returns the host name of the Internet host specified by ip_address. If an error occurs, returns 

ip_address. 

See also gethostbynameQ . 

Prev Home Next 

fsockopen Ug gethostbyname 



PHP Manual 

Prev Next 



gethostbyname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gethostbyname ~ Get the IP address corresponding to a given Internet host name. 

Description 

string gethostbyname(string hostname); 

Returns the IP address of the Internet host specified by hostname. 

See also gethostby addrQ . 

Prev Home Next 

gethostbyaddr U^ gethostbynamel 



PHP Manual 

Prev Next 



gethostbynamel 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gethostbynamel ~ Get a Hst of IP addresses corresponding to a given Internet host name. 

Description 

array gethostbynamel(string hostname); 

Returns a Hst of IP addresses to which the Internet host specified by hostname resolves. 

See also gethostbynameQ , gethostbyaddrQ , checkdnsrrQ , getmxrrQ , and the named(8) manual 
page. 

Prev Home Next 

gethostbyname U^ getmxrr 



PHP Manual 

Prev Next 



getmxrr 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



getmxrr ~ Get MX records corresponding to a given Internet host name. 

Description 

int getmxrr (string hostname, array mxhosts, array [weight]); 

Searches DNS for MX records corresponding to hostname. Returns true if any records are found; 
returns false if no records were found or if an error occurred. 

A Hst of the MX records found is placed into the array mxhosts. If the weight array is given, it 
will be filled with the weight information gathered. 

See also checkdnsrrQ , gethostbynameQ , gethostbynamelQ , gethostbyaddrQ , and the named(8) 
manual page. 

Prev Home Next 

gethostbynamel Up getprotobyname 



PHP Manual 

Prev Next 



getprotobyname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getprotobyname ~ get protocol number associated with protocol name 

Description 

int getprotobyname(string name); 

getprotobynameO returns the protocol number associated with the protocol name as per 
/etc/protocols. See also getprotoby number () . 

Prev Home Next 

getmxrr Up getprotobynumber 



PHP Manual 

Prev Next 



getprotobynumber 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getprotobynumber ~ get protocol name associated with protocol number 

Description 

string getprotobynumber(int number); 

getprotoby number returns the protocol name associated with protocol number as per 
/etc/protocols. See also getprotobynameQ . 

Prev Home Next 

getprotobyname Up getservbyname 



PHP Manual 

Prev Next 



getservbyname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



getservbyname ~ get port number associated with an Internet service and protocol 

Description 

int getservbyname(string service, string protocol); 

getservbynameO returns the Internet port which corresponds to service for the specified 
protocol as per /etc/services, protocol is either tcp or udp. See also getservbyportQ . 

Prev Home Next 

getprotobynumber Up getservbyport 



PHP Manual 

Prev Next 



getservbyport 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

getservbyport ~ get Internet service which corresponds to port and protocol 

Description 

string getservbyport(int port, string protocol); 

getservbyportO returns the Internet service associated with port for the specified protocol as 
per /etc/services, protocol is either tcp or udp. See also getservbynameQ . 

Prev Home Next 

getservbyname Up openlog 



PHP Manual 

Prev Next 



openlog 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

openlog ~ open connection to system logger 

Description 

int openlog(string ident, int option, int facility); 

openlogO opens a connection to the system logger for a program. The string ident is added to 
each message. Values for option and facility are given in the next section. The use of 
OpenlogO is optional; It will automatically be called by syslogQ if necessary, in which case ident 
will default to false. See also syslogQ and closelogQ . 

Prev Home Next 

getservbyport Up pfsockopen 



PHP Manual 

Prev Next 



ada_afetch 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_afetch ~ fetch a result row into an array 

Description 

See odbc_fetch_into() 



Prev Home Next 

Adabas D functions Up ada_autocommit 



PHP Manual 

Prev Next 



ada_autocommit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_autocommit ~ toggle autocommit behaviour 

Description 

See odbc_autocommit() . 



Prev Home Next 

ada_afetch Up ada_close 



PHP Manual 

Prev Next 



ada close 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_close ~ close a connection to an Adabas D server 

Description 

See odbc_close(). 



Prev Home Next 

ada_autocommit Up ada_commit 



PHP Manual 

Prev Next 



ada_commit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_commit ~ commit a transaction 

Description 

See odbc_commit() 



Prev Home Next 

ada_close Up ada_connect 



PHP Manual 

Prev Next 



ada_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_connect ~ connect to an Adabas D datasource 

Description 

See odbc_connect(). 



Prev Home Next 

ada_commit Up ada_exec 



PHP Manual 

Prev Next 



ada exec 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_exec ~ prepare and execute a SQL statement 

Description 

See odbc_exec() or odbc_do(). 



Prev Home Next 

ada_connect Ug ada_fetchrow 



PHP Manual 

Prev Next 



ada_f etch row 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_fetchrow ~ fetch a row from a result 

Description 

See odbc_f etch_ro w() . 



Prev Home Next 

ada_exec Up ada_fieldname 



PHP Manual 

Prev Next 



ada_fieldname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_fieldname ~ get the columnname 

Description 

See odbc_field_name(). 



Prev Home Next 

ada_fetchrow Up ada_fieldnum 



PHP Manual 

Prev Next 



ada_fieldnum 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_fieldnum ~ get column number 

Description 

See odbc_field_num(). 



Prev Home Next 

ada_fieldname Ug ada_fieldtype 



PHP Manual 

Prev Next 



ada_fieldtype 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_fieldtype ~ get the datatype of a field 

Description 

See odbc_field_type(). 



Prev Home Next 

ada_fieldnum Up ada_freeresult 



PHP Manual 

Prev Next 



ada_freeresult 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_freeresult ~ >free resources associated with a result 

Description 

See odbc_f ree_result() . 



Prev Home Next 

ada_fieldtype Up ada_numfields 



PHP Manual 

Prev Next 



ada_numfields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_numfields ~ get the number of columns in a result 

Description 

See odbc_num_fields() . 



Prev Home Next 

ada_freeresult Up ada_numrows 



PHP Manual 

Prev Next 



ada_numrows 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_numrows ~ number of rows in a result 

Description 

See odbc_num_rows() . 



Prev Home Next 

ada_numfields Up ada_result 



PHP Manual 

Prev Next 



ada result 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ada_result ~ get data from results 

Description 

See odbc_result(). 



Prev Home Next 

ada_numrows Up ada_resultall 



PHP Manual 

Prev Next 



ada_resultall 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ada_resultall ~ print result as HTML table 

Description 

See odbc_result_all(). 



Prev Home Next 

ada_result Up ada_rollback 



PHP Manual 

Prev Next 



JDToGregorian 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

JDToGregorian ~ Converts JuHan Day Count to Gregorian date 

Description 

string jdtogregorian(int juHanday); 

Converts Juhan Day Count to a string containing the Gregorian date in the format of 
"month/day/year" 

Prev Home Next 

Calendar functions Up GregorianToJD 



PHP Manual 

Prev Next 



GregorianToJD 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

GregorianToJD ~ Converts a Gregorian date to JuHan Day Count 

Description 

int gregorianto jd(int month, int day, int year); 

Vahd Range for Gregorian Calendar 4714 B.C. to 9999 A.D. 

Although this software can handle dates all the way back to 4714 B.C., such use may not be 
meaningful. The Gregorian calendar was not instituted until October 15, 1582 (or October 5, 1582 
in the Julian calendar). Some countries did not accept it until much later. For example, Britain 
converted in 1752, The USSR in 1918 and Greece in 1923. Most European countries used the 
Julian calendar prior to the Gregorian. 

Example 1. Calendar functions 

<?php 

$jd = GregorianToJD (10, 11, 1970) ; 

echo ( " $ jd\n" ) ; 

$gregorian = JDToGregorian ($ jd) ; 

echo ( "$gregorian\n" ) ; 

?> 

Prev Home Next 

JDToGregorian Ug JDToJulian 



PHP Manual 

Prev Next 



JDToJulian 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



JDToJuHan ~ Converts a JuHan Calendar date to JuHan Day Count 

Description 

string jdto julian(int juHanday); 

Converts Juhan Day Count to a string containing the JuHan Calendar Date in the format of 
"month/day/year" . 

Prev Home Next 

GregorianToJD Up JulianToJD 



PHP Manual 

Prev Next 



JulianToJD 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



JuHanToJD ~ Converts a JuHan Calendar date to JuHan Day Count 

Description 

int julianto jd(int month, int day, int year); 

Vahd Range for Juhan Calendar 4713 B.C. to 9999 A.D. 

Although this software can handle dates all the way back to 4713 B.C., such use may not be 
meaningful. The calendar was created in 46 B.C., but the details did not stabilize until at least 8 
A.D., and perhaps as late at the 4th century. Also, the beginning of a year varied from one culture to 
another - not all accepted January as the first month. 

Prev Home Next 

JDToJulian Up JDToJewish 



PHP Manual 

Prev Next 



J DTo Jewish 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



JDToJewish — Converts a JuHan Day Count to the Jewish Calendar 

Description 

string jdto jewish(int juHanday); 

Converts a JuHan Day Count the the Jewish Calendar. 

Prev Home Next 

JulianToJD Up JewishToJD 



PHP Manual 

Prev Next 



JewishToJD 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



JewishToJD — Converts a date in the Jewish Calendar to JuHan Day Count 

Description 

int jewishto jd(int month, int day, int year); 

VaUd Range Although this software can handle dates all the way back to the year 1 (3761 B.C.), 
such use may not be meaningful. 

The Jewish calendar has been in use for several thousand years, but in the early days there was no 
formula to determine the start of a month. A new month was started when the new moon was first 
observed. 

Prev Home Next 

JDToJewish Up JDToFrench 



PHP Manual 

Prev Next 



JDToFrench 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



JDToFrench ~ Converts a JuHan Day Count to the French RepubUcan Calendar 

Description 

string jdtof rench(int month, int day, int year); 
Converts a JuHan Day Count to the French RepubUcan Calendar. 

Prev Home Next 

JewishToJD Up FrenchToJD 



PHP Manual 

Prev Next 



FrenchToJD 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



FrenchToJD ~ Converts a date from the French RepubHcan Calendar to a JuHan Day Count 

Description 

int f renchto jd(int month, int day, int year); 

Converts a date from the French RepubHcan Calendar to a Julian Day Count 

These routines only convert dates in years 1 through 14 (Gregorian dates 22 September 1792 
through 22 September 1806). This more than covers the period when the calendar was in use. 

Prev Home Next 

JDToFrench Ug JDMonthName 



PHP Manual 

Prev Next 



JDMonthName 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

JDMonthName ~ Returns a month name 

Description 

string jdmonthname(int juHanday, intmode); 

Returns a string containing a month name, mode tells this function which calendar to convert the 
Julian Day Count to, and what type of month names are to be returned. 



Table 1. Calendar modes 



Mode 


Meaning 





Gregorian - apreviated 


1 


Gregorian 


2 


Julian - apreviated 


3 


Julian 


4 


Jewish 


5 


French Republican 



Prev Home Next 

FrenchToJD Ug JDDayOfWeek 



PHP Manual 

Prev Next 



JDDayOfWeek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

JDDayOfWeek ~ Returns the day of the week 

Description 



mixed jddayofweek(int juHanday, intmode); 

Returns the day of the week. Can return a string or an int depending on the mode. 

Table 1. Calendar week modes 



Mode 







Meaning 



returns the day number as an int (0=sunday, l=monday, etc) 



returns string containing the day of week (enghsh-gregorian) 



returns a string containing the abreviated day of week (enghsh-gregorian) 



Prev Home Next 

JDMonthName Up easter_date 



PHP Manual 

Prev Next 



easter date 



This function is not supported in t 

PHP Lite edition. 

Possible workaround not yet published. 



ished. I 



easter_date ~ get UNIX timestamp for midnight on Easter of a given year 

Description 

int easter_date(int year); 

Returns the UNIX timestamp corresponding to midnight on Easter of the given year. If no year is 
specified, the current year is assumed. 

Warning: This function will generate a warning if the year is outside of the range for UNIX 
timestamps (i.e. before 1970 or after 2037). 

Example 1. easter_date() example 

echo date ( "M-d-Y", easter_date ( 1999) ); /* "Apr-04-1999" */ 

echo date ( "M-d-Y", easter_date (2000 ) ); /* "Apr-23-2000" */ 

echo date ( "M-d-Y", easter_date (2001 ) ); /* "Apr-15-2001" */ 

The date of Easter Day was defined by the Council of Nicaea in AD325 as the Sunday after the first 
full moon which falls on or after the Spring Equinox. The Equinox is assumed to always fall on 21st 
March, so the calculation reduces to determining the date of the full moon and the date of the 
following Sunday. The algorithm used here was introduced around the year 532 by Dionysius 
Exiguus. Under the Julian Calendar (for years before 1753) a simple 19-year cycle is used to track 
the phases of the Moon. Under the Gregorian Calendar (for years after 1753 - devised by Clavius 
and Lilius, and introduced by Pope Gregory XIII in October 1582, and into Britain and its then 
colonies in September 1752) two correction factors are added to make the cycle more accurate. 

(The code is based on a C program by Simon Kershaw, <webmaster@ely.anglican.org>) 

See easter_days() for calculating Easter before 1970 or after 2037. 

Prev Home Next 

JDDayOfWeek U^ easter_days 



PHP Manual 

Prev Next 



easter_days 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



easter_days ~ get number of days after March 21 on which Easter falls for a given year 

Description 

int easter_days(int year); 

Returns the number of days after March 21 on which Easter falls for a given year. If no year is 
specified, the current year is assumed. 

This function can be used instead of easter_date() to calculate Easter for years which fall outside 
the range of UNIX timestamps (i.e. before 1970 or after 2037). 
Example 1. easter_date() example 

echo easter_days ( 1999) 
echo easter_days ( 1492 ) 
echo easter_days ( 1913) 

The date of Easter Day was defined by the Council of Nicaea in AD325 as the Sunday after the first 
full moon which falls on or after the Spring Equinox. The Equinox is assumed to always fall on 
21st March, so the calculation reduces to determining the date of the full moon and the date of the 
following Sunday. The algorithm used here was introduced around the year 532 by Dionysius 
Exiguus. Under the Julian Calendar (for years before 1753) a simple 19-year cycle is used to track 
the phases of the Moon. Under the Gregorian Calendar (for years after 1753 - devised by Clavius 
and Lilius, and introduced by Pope Gregory XIII in October 1582, and into Britain and its then 
colonies in September 1752) two correction factors are added to make the cycle more accurate. 

(The code is based on a C program by Simon Kershaw, <webmaster@ely.anglican.org>) 

See also easter_date() . 

Prev Home Next 

easter_date Up ClibPDF functions 



/* 


14, 


i.e. 


April 


4 


V 


/* 


32, 


i.e. 


April 


22 


V 


/* 


2, 


i.e. 


March 


23 


V 



PHP Manual 

Prev Next 



cpdf_set_creator 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_creator ~ Sets the creator field in the pdf document 

Description 

void cpdf_set_cr eat or (string creator); 

The cpdf_set_creator() function sets the creator of a pdf document. 

See also cpdf_set_subject() , cpdf_set_title() , cpdf_set_keywords() . 

Prev Home Next 

ClibPDF functions U^ cpdf_set_title 



PHP Manual 

Prev Next 



cpdf_open 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_open — Opens a new pdf document 

Description 

int cpdf_open(int compression, string filename); 

The cpdf_open() function opens a new pdf document. The first parameter turns document 
compression on if it is unequal to 0. The second optional parameter sets the file in which the 
document is written. If it is omitted the document is created in memory and can either be written 
into a file with the cpdf_save_to_file() or written to standard output with cpdf_output_buffer() . 

Note: The return value will be needed in futher versions of ClibPDF as the first 
parameter in all other functions which are writing to the pdf document. 

The ClibPDF library takes the filename "-" as a synonym for stdout. If PHP is 
compiled as an apache module this will not work because the way ClibPDF outputs to 
stdout does not work with apache. You can solve this problem by skipping the 
filename and using cpdf_output_buffer() to output the pdf document. 

See also cpdf_close() , cpdf_output_buffer() . 

Prev Home Next 

cpdf_set_keywords Up cpdf_close 



PHP Manual 

Prev Next 



cpdf_set_font 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_font ~ Select the current font face and size 

Description 

void cpdf_set_f ont(int pdf document, string font name, double size, string encoding); 

The cpdf_set_font() function sets the the current font face, font size and encoding. Currently only 
the standard postscript fonts are supported. The last parameter encoding can take the following 
values: "MacRomanEncoding", "MacExpertEncoding", "WinAnsiEncoding", and "NULL". 
"NULL" stands for the font's built-in encoding. See the ClibPDF Manual for more information, 
especially how to support asian fonts. 

Prev Home Next 

cpdf_text Ug cpdf_set_leading 



PHP Manual 

Prev Next 



PDF_translate 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

PDF_translate ~ Sets origin of coordinate system 

Description 

void pdf_t ranslate(int pdf document, double x-koor, double y-koor); 

The PDF_translate() function set the origin of coordinate system to the point (x-koor, y-koor). 

The following example draws a line from (0, 0) to (200, 200) relative to the initial coordinate 

system. You have to set the current point after PDF_translate() and before you start drawing more 

objects. 

Example 1. Translation 

<?php PDF_moveto ($pdf , 0, 0); 
PDF_lineto ($pdf , 100, 100); 
PDF_stroke ($pdf ) ; 
PDF_translate ($pdf , 100, 100); 
PDF_moveto ($pdf , 0, 0); 
PDF_lineto ($pdf , 100, 100); 
PDF_stroke ($pdf ) ; 
?> 

Prev Home Next 

PDF_restore Up PDF_scale 



PHP Manual 

Prev Next 



cpdf_set_title 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_title ~ Sets the title field of the pdf document 

Description 

void cpdf_set_title(string title); 

The cpdf_set_title() function sets the title of a pdf document. 

See also cpdf_set_subject() , cpdf_set_creator() , cpdf_set_key wordsQ . 

Prev Home Next 

cpdf_set_creator Ug cpdf_set_subject 



PHP Manual 

Prev Next 



cpdf_set_subiect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_subject ~ Sets the subject field of the pdf document 

Description 

void cpdf_set_sub ject(string subject); 

The cpdf_set_subject() function sets the subject of a pdf document. 

See also cpdf_set_title() , cpdf_set_creator() , cpdf_set_key wordsQ . 

Prev Home Next 

cpdf_set_title U^ cpdf_set_keywords 



PHP Manual 

Prev Next 



cpdf_set_keywords 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_keywords ~ Sets the keywords field of the pdf document 

Description 

void cpdf_set_keywords(string keywords); 

The cpdf_set_keywords() function sets the keywords of a pdf document. 

See also cpdf_set_title() , cpdf_set_creator() , cpdf _set_subj ect() . 

Prev Home Next 

cpdf_set_subject U^ cpdf_open 



PHP Manual 

Prev Next 



cpdf_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_close ~ Closes the pdf document 

Description 

void cpdf_close(int pdf document); 

The cpdf_close() function closes the pdf document. This should be the last function even after 
cpdf_finalize() , cpdf_output_buffer() and cpdf_save_to_file() . 

See also cpdf_open() . 

Prev Home Next 

cpdf_open Ug cpdf_page_init 



PHP Manual 

Prev Next 



cpdf_page_init 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_page_init ~ Starts new page 

Description 



void cpdf_page_init(int pdf document, int page number, int orientation, double height, 
double width, double unit); 

The cpdf_page_init() function starts a new page with height height and width width. The page 
has number page number and orientation orientation, orientation can be for portrait 
and 1 for landscape. The last optional parameter unit sets the unit for the koordinate system. The 
value should be the number of postscript points per unit. Since one inch is equal to 72 points, a 
value of 72 would set the unit to one inch. The default is also 72. 

See also cpdf_set_current_page() . 

Prev Home Next 

cpdf_close Up cpdf_finalize_page 



PHP Manual 

Prev Next 



cpdf_finalize_page 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_finaHze_page ~ Ends page 

Description 

void cpdf_finalize_page(intpdf document, int page number); 

The cpdf_finalize_page() function ends the page with page number page number. This function 
is only for saving memory. A finahzed page takes less memory but cannot be modified anymore. 

See also cpdf_page_init() . 

Prev Home Next 

cpdf_page_init U^ cpdf_finalize 



PHP Manual 

Prev Next 



cpdMinalize 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_finaHze ~ Ends document 

Description 

void cpdf_finalize(intpdf document); 

The cpdf_finalize() function ends the document. You still have to call cpdf_dose() . 

See also cpdf_close() . 

Prev Home Next 

cpdf_finalize_page Ug cpdf_output_buffer 



PHP Manual 

Prev Next 



cpdf_output_buffer 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_output_buffer ~ Outputs the pdf document in memory buffer 

Description 

void cpdf_output_buf f er(int pdf document); 

The cpdf_output_buffer() function outputs the pdf document to stdout. The document has to be 
created in memory which is the case if cpdf_open() has been called with no filename parameter. 

See also cpdf_open() . 

Prev Home Next 

cpdf_finalize U^ cpdf_save_to_file 



PHP Manual 

Prev Next 



cpdf_save_to_f i le 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_save_to_file ~ Writes the pdf document into a file 

Description 

void cpdf_save_to_f ile(int pdf document, string filename); 

The cpdf_save_to_file() function outputs the pdf document into a file if it has been created in 
memory. This function is not needed if the pdf document has been open by specifying a filename as 
a parameter of cpdf_open() . 

See also cpdf_output_buf fer () , cpdf_open() . 

Prev Home Next 

cpdf_output_buffer Ug cpdf_set_current_page 



PHP Manual 

Prev Next 



cpdf_set_cu r rent_page 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_current_page ~ Sets current page 

Description 

void cpdf_set_current_page(int pdf document, int page number); 

The cpdf_set_current_page() function set the page on which all operations are performed. One 
can switch between pages until a page is finished with cpdf_finalize_page() . 

See also cpdf_finalize_page() . 

Prev Home Next 

cpdf_save_to_file U^ cpdf_begin_text 



PHP Manual 

Prev Next 



cpdf_begin_text 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_begin_text ~ Starts text section 

Description 



void cpdf_begin_text(int pdf document); 

The cpdf_begin_text() function starts a text section. It must be ended with cpdf_end_text() . 
Example 1. Text output 

<?php cpdf_begin_text ($pdf ) ; 

cpdf_set_f ont ( $pdf , 16, "Helvetica", "WinAnsiEncoding" ) ; 

cpdf_text ($pdf , 100, 100, "Some text"); 

cpdf_end_text ( $pdf ) ?> 

See also cpdf_end_text() . 

Prev Home Next 

cpdf_set_current_page U^ cpdf_end_text 



PHP Manual 

Prev Next 



cpdf_end_text 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_end_text ~ Starts text section 

Description 



void cpdf_end_text(int pdf document); 

The cpdf_end_text() function ends a text section which was started with cpdf_begin_text() . 
Example 1. Text output 

<?php cpdf_begin_text ($pdf ) ; 

cpdf_set_f ont ( $pdf , 16, "Helvetica", "WinAnsiEncoding" ) ; 

cpdf_text ($pdf , 100, 100, "Some text"); 

cpdf_end_text ( $pdf ) ?> 

See also cpdf_begin_text() . 

Prev Home Next 

cpdf_begin_text U^ cpdf_show 



PHP Manual 

Prev Next 



cpdf_show 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_show ~ Output text at current position 

Description 

void cpdf_show(int pdf document, string text); 

The cpdf_show() function outputs the string in text at the current position. 

See also cpdf_text() , cpdf_begin_text() , cpdf_end_text() . 

Prev Home Next 

cpdf_end_text U^ cpdf_show_xy 



PHP Manual 

Prev Next 



cpdf_show_xy 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_show_xy — Output text at position 

Description 



void cpdf_show_xy(int pdf document, string text, double x-koor, double y-koor, int mode); 

The cpdf_show_xy() function outputs the string text at position with coordinates (x-koor, 
y-koor). The last optional parameter determines the unit length. If is or omitted the default unit 
as specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

Note: The function cpdf_show_xy() is identical to cpdf_text() without the optional 
parameters. 

See also cpdf_text() . 

Prev Home Next 

cpdf_show Ug cpdf_text 



PHP Manual 

Prev Next 



cpdf_text 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_text ~ Output text with parameters 

Description 

void cpdf_text(int pdf document, string text, double x-koor, double y-koor, int mode, double 
orientation, int alignmode); 

The cpdf_text() function outputs the string text at position with coordinates (x-koor, 
y-koor). The optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. The optional parameter orientation is the rotation of the text in 
degree. The optional parameter alignmode determines how the text is align. See the ClibPDF 
documentation for possible values. 

See also cpdf_show_xy () . 

Prev Home Next 

cpdf_show_xy Up cpdf_set_font 



PHP Manual 

Prev Next 



cpdf_set_leading 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_leading — Sets distance between text Hnes 

Description 

void cpdf_set leading(int pdf document, double distance); 

The cpdf_set_leading() function sets the distance between text Hnes. This will be used if text is 
output by cpdf_continue_text() . 

See also cpdf_continue_text() . 

Prev Home Next 

cpdf_set_font U^ cpdf_set_text_rendering 



PHP Manual 

Prev Next 



cpdf_set_text_rendering 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_text_rendering ~ Determines how text is rendered 

Description 

void cpdf_set_text_rendering(int pdf document, int mode); 

The cpdf_set_text_rendering() function determines how text is rendered. The possible values for 
mode are 0=fill text, l=stroke text, 2=fill and stroke text, 3=invisible, 4=fill text and add it to 
cliping path, 5=stroke text and add it to clipping path, 6=fill and stroke text and add it to cliping 
path, 7=add it to clipping path. 

Prev Home Next 

cpdf_set_leading Ug cpdf_set_horiz_scaling 



PHP Manual 

Prev Next 



cpdf_set_horiz_scaling 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_horiz_scaHng ~ Sets horizontal scahng of text 

Description 

void cpdf_set_horiz_scaling(intpdf document, double scale); 

The cpdf_set_horiz_scaling() function sets the horizontal scaling to scale percent. 

Prev Home Next 

cpdf_set_text_rendering Up cpdf_set_text_rise 



PHP Manual 

Prev Next 



cpdf_set_text_rise 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_text_rise ~ Sets the text rise 

Description 

void cpdf_set_text_rise(intpdf document, double value); 
The cpdf_set_text_rise() function sets the text rising to value units. 

Prev Home Next 

cpdf_set_horiz_scaling Up cpdf_set_text_matrix 



PHP Manual 

Prev Next 



cpdf_set_text_matrix 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_text_matrix ~ Sets the text matrix 

Description 

void cpdf_set_text_mat rix(int pdf document, array matrix); 

The cpdf_set_text_matrix() function sets a matrix which describes a transformation appHed on the 
current text font. 

Prev Home Next 

cpdf_set_text_rise Up cpdf_set_text_pos 



PHP Manual 

Prev Next 



cpdf_set_text_pos 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_text_pos ~ Sets text position 

Description 



void cpdf_set_text_pos(int pdf document, double x-koor, double y-koor, int mode); 
The cpdf_set_text_pos() function sets the position of text for the next cpdf_show() function call. 

The last optional parameter mode determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_show() , cpdf_text() . 

Prev Home Next 

cpdf_set_text_matrix Up cpdf_set_char_spacing 



PHP Manual 

Prev Next 



cpdf_set_char_spacing 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_char_spacing ~ Sets character spacing 

Description 

void cpdf_set_char_spacing(int pdf document, double space); 
The cpdf_set_char_spacing() function sets the spacing between characters. 
See also cpdf_set_word_spacing() , cpdf_set_leading() . 

Prev Home Next 

cpdf_set_text_pos U^ cpdf_set_word_spacing 



PHP Manual 

Prev Next 



cpdf_set_word_spacing 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_word_spacing ~ Sets spacing between words 

Description 

void cpdf_set_word_spacing(int pdf document, double space); 
The cpdf_set_word_spacing() function sets the spacing between words. 
See also cpdf_set_char_spacing() , cpdf_set_leading() . 

Prev Home Next 

cpdf_set_char_spacing Ug cpdf_continue_text 



PHP Manual 

Prev Next 



cpdf_continue_text 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_continue_text ~ Output text in next Hne 

Description 

void cpdf_continue_text(intpdf document, string text); 

The cpdf_continue_text() function outputs the string in text in the next Hne. 

See also cpdf_show_xy() , cpdf_text() , cpdf_set_leading() , cpdf_set_text_pos() . 

Prev Home Next 

cpdf_set_word_spacing U^ cpdf_stringwidth 



PHP Manual 

Prev Next 



cpdf_stringwidth 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_stringwidth ~ Returns width of text in current font 

Description 

double cpdf_stringwidth(intpdf document, string text); 

The cpdf_stringwidth() function returns the width of the string in text. It requires a font to be set 
before. 

See also cpdf_set_font() . 

Prev Home Next 

cpdf_continue_text U^ cpdf_save 



PHP Manual 

Prev Next 



cpdf_save 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_save ~ Saves current enviroment 

Description 

void cpdf_save(int pdf document); 

The cpdf_save() function saves the current enviroment. It works Hke the postscript command 
gsave. Very useful if you want to translate or rotate an object without effecting other objects. 

See also cpdf_restore() . 

Prev Home Next 

cpdf_stringwidth U^ cpdf_restore 



PHP Manual 

Prev Next 



cpdf_restore 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_restore ~ Restores formerly saved enviroment 

Description 

void cpdf_restore(intpdf document); 

The cpdf_restore() function restores the enviroment saved with cpdf_save() . It works Hke the 
postscript command grestore. Very useful if you want to translate or rotate an object without 
effecting other objects. 

Example 1. Save/Restore 

<?php cpdf_save ($pdf ) ; 

// do all kinds of rotations, transformations, . . . 

cpdf_restore ($pdf ) ?> 

See also cpdf_save() . 

Prev Home Next 

cpdf_save U^ cpdf_translate 



PHP Manual 

Prev Next 



cpdf_translate 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_translate ~ Sets origin of coordinate system 

Description 



void cpdf_t ranslate(int pdf document, double x-koor, double y-koor, int mode); 

The cpdf_translate() function set the origin of coordinate system to the point (x-koor, y-koor). 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

Prev Home Next 

cpdf_restore Up cpdf_scale 



PHP Manual 

Prev Next 



cpdf_scale 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_scale ~ Sets scaHng 

Description 

void cpdf_scale(int pdf document, double x-scale, double y-scale); 
The cpdf_scale() function set the scaling factor in both directions. 

Prev Home Next 

cpdf_translate Up cpdf_rotate 



PHP Manual 

Prev Next 



cpdf_rotate 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_rotate ~ Sets rotation 

Description 

void cpdf_rotate(int pdf document, double angle); 

The cpdf_rotate() function set the rotation in degress to angle. 

Prev Home Next 

cpdf_scale Up cpdf_setflat 



PHP Manual 

Prev Next 



cpdf_setflat 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_setflat ~ Sets flatness 

Description 

void cpdf_setf lat(int pdf document, double value); 

The cpdf_setflat() function set the flatness to a value between and 100. 

Prev Home Next 

cpdf_rotate Up cpdf_setlinejoin 



PHP Manual 

Prev Next 



cpdf_setlinejoin 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setHnejoin ~ Sets Hnejoin parameter 

Description 

void cpdf_setlinejoin(intpdf document, long value); 

The cpdf_setlinejoin() function set the linejoin parameter between a value of and 2.0 = miter, 1 
= round, 2 = bevel. 

Prev Home Next 

cpdf_setflat Up cpdf_setlinecap 



PHP Manual 

Prev Next 



cpdf_setlinecap 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setHnecap ~ Sets Hnecap aparameter 

Description 

void cpdf_setlinecap(int pdf document, int value); 

The cpdf_setlinecap() function set the Hnecap parameter between a value of and 2.0 = butt end, 
1 = round, 2 = projecting square. 

Prev Home Next 

cpdf_setlinejoin Up cpdf_setmiterlimit 



PHP Manual 

Prev Next 



cpdf_setmiterlimit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setmiterHmit ~ Sets miter Hmit 

Description 



void cpdf_setmiterlimit(intpdf document, double value); 

The cpdf_setmiterlimit() function set the miter limit to a value greater or equal than 1 . 

Prev Home Next 

cpdf_setlinecap Up cpdf_setlinewidth 



PHP Manual 

Prev Next 



cpdf_setlinewidth 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setHnewidth ~ Sets Hne width 

Description 

void cpdf_setlinewidth(int pdf document, double width); 
The cpdf_setlinewidth() function set the Hne width to width. 

Prev Home Next 

cpdf_setmiterHmit Up cpdf_setdash 



PHP Manual 

Prev Next 



cpdf_setdash 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_setdash — Sets dash pattern 

Description 

void cpdf_setdash(int pdf document, double white, double black); 

The cpdf_setdash() function set the dash pattern white white units and black black units. If 
both are a solid line is set. 

Prev Home Next 

cpdf_setlinewidth Up cpdf_moveto 



PHP Manual 

Prev Next 



cpdf_moveto 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_moveto ~ Sets current point 

Description 

void cpdf_moveto(int pdf document, double x-koor, double y-koor, int mode); 

The cpdf_moveto() function set the current point to the coordinates x-koor and y-koor. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

Prev Home Next 

cpdf_setdash Up cpdf_rmoveto 



PHP Manual 

Prev Next 



cpdf_rmoveto 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_rmoveto ~ Sets current point 

Description 

void cpdf_rmoveto(int pdf document, double x-koor, double y-koor, int mode); 

The cpdf_rmoveto() function set the current point relative to the coordinates x-koor and 
y-koor. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_moveto() . 

Prev Home Next 

cpdf_moveto Up cpdf_curveto 



PHP Manual 

Prev Next 



cpdf_curveto 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_curveto ~ Draws a curve 

Description 

void cpdf_curveto(int pdf document, double xl, double yl, double x2, double y2, double x3, 
double y3, int mode); 

The cpdf_curveto() function draws a Bezier curve from the current point to the point (x3, y3) 
using (xl, yl) and (x2, y2) as control points. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_moveto() , cpdf_rmoveto() , cpdf_rlineto() , cpdf_lineto() . 

Prev Home Next 

cpdf_rmoveto U^ cpdf_lineto 



PHP Manual 

Prev Next 



cpdfjineto 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdfjineto ~ Draws a Hne 

Description 

void cpdf_lineto(int pdf document, double x-koor, double y-koor, int mode); 

The cpdf_lineto() function draws a line from the current point to the point with coordinates 

(x-koor, y-koor). 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_moveto() , cpdf_rmoveto() , cpdf_curveto() . 

Prev Home Next 

cpdf_curveto Ug cpdf_rlineto 



PHP Manual 

Prev Next 



cpdf_rlineto 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_rHneto ~ Draws a Hne 

Description 

void cpdf_rlineto(int pdf document, double x-koor, double y-koor, int mode); 

The cpdf_rlineto() function draws a line from the current point to the relative point with 
coordinates (x-koor, y-koor). 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_moveto() , cpdf_rmoveto() , cpdf_curveto() . 

Prev Home Next 

cpdf_lineto Ug cpdf_circle 



PHP Manual 

Prev Next 



cpdf_circle 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_circle ~ Draw a circle 

Description 

void cpdf_circle(int pdf document, double x-koor, double y-koor, double radius, int mode); 

The cpdf_circle() function draws a circle with center at point (x-koor, y-koor) and radius 
radius. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_arc() . 

Prev Home Next 

cpdf_rlineto Up cpdf_arc 



PHP Manual 

Prev Next 



cpdf_arc 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_arc ~ Draws an arc 

Description 

void cpdf_arc(int pdf document, double x-koor, double y-koor, double radius, double start, 
double end, int mode); 

The cpdf_arc() function draws an arc with center at point (x-koor, y-koor) and radius 
radius, starting at angle start and ending at angle end. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_circle() . 

Prev Home Next 

cpdf_circle U^ cpdf_rect 



PHP Manual 

Prev Next 



cpdf_rect 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_rect ~ Draw a rectangle 

Description 

void cpdf_rect(int pdf document, double x-koor, double y-koor, double width, double height, 
int mode); 

The cpdf_rect() function draws a rectangle with its lower left corner at point (x-koor, y-koor). 
This width is set to wldgth. This height is set to height. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

Prev Home Next 

cpdf_arc Up cpdf_closepath 



PHP Manual 

Prev Next 



cpdf_closepath 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_closepath ~ Close path 

Description 

void cpdf_closepath(int pdf document); 

The cpdf_closepath() function closes the current path. 

Prev Home Next 

cpdf_rect Up cpdf_stroke 



PHP Manual 

Prev Next 



cpdf_stroke 

cpdf_stroke ~ Draw line along path 

Description 

void cpdf_stroke(intpdf document); 

The cpdf_stroke() function draws a line along current path. 

See also cpdf_closepath() , cpdf_closepath_stroke() . 

Prev Home Next 

cpdf_closepath Up cpdf_closepath_stroke 



PHP Manual 

Prev Next 



cpdf_closepath_stroke 

cpdf_closepath_stroke ~ Close path and draw line along path 

Description 

void cpdf_closepath_stroke(intpdf document); 

The cpdf_closepath_stroke() function is a combination of cpdf_closepath() and cpdf_stroke() . 
Than clears the path. 

See also cpdf_closepath() , cpdf_stroke() . 

Prev Home Next 

cpdf_stroke Up cpdf_fill 



PHP Manual 

Prev Next 



cpdfjill 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_fill ~ Fill current path 

Description 

void cpdf_fill(intpdf document); 

The cpdf_fill() function fills the interior of the current path with the current fill color. 

See also cpdf_closepath() , cpdf_stroke() , cpdf_setgray_fill() , cpdf_setgray() , 
cpdf_setrgbcolor_fill() , cpdf_setrgbcolor() . 

Prev Home Next 

cpdf_closepath_stroke U^ cpdf_fill_stroke 



PHP Manual 

Prev Next 



cpdf_fill_stroke 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_fill_stroke ~ Fill and stroke current path 

Description 

void cpdf_fill_stroke(intpdf document); 

The cpdf_fill_stroke() function fills the interior of the current path with the current fill color and 
draws current path. 

See also cpdf_closepath() , cpdf_stroke() , cpdf_fill() , cpdf_setgray_fill() , cpdf_setgray() , 
cpdf_setrgbcolor_fill() , cpdf_setrgbcolor() . 

Prev Home Next 

cpdf_fill U^ cpdf_closepath_fill_stroke 



PHP Manual 

Prev Next 



cpdf_closepath_f i I l_stroke 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_closepath_fill_stroke ~ Close, fill and stroke current path 

Description 

void cpdf_closepath_fill_stroke(intpdf document); 

The cpdf_closepath_fill_stroke() function closes, fills the interior of the current path with the 
current fill color and draws current path. 

See also cpdf_closepath() , cpdf_stroke() , cpdf_fill() , cpdf_setgray_fill() , cpdf_setgray() , 
cpdf_setrgbcolor_fill() , cpdf_setrgbcolor() . 

Prev Home Next 

cpdf_fill_stroke U^ cpdf_clip 



PHP Manual 

Prev Next 



cpdf_clip 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_cHp — cups to current path 

Description 

void cpdf_clip(intpdf document); 

The cpdf_clip() function cHps all drawing to the current path. 



Prev Home Next 

cpdf_closepath_fill_stroke Up cpdf_setgray_fill 



PHP Manual 

Prev Next 



cpdf_setgray_fill 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setgray_fill ~ Sets filHng color to gray value 

Description 

void cpdf_setgray_f ill(int pdf document, double value); 

The cpdf_setgray_fill() function sets the current gray value to fill a path. 

See also cpdf_setrgbcolor_fill() . 

Prev Home Next 

cpdf_clip U^ cpdf_setgray_stroke 



PHP Manual 

Prev Next 



cpdf_setg ray_stroke 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setgray_stroke ~ Sets drawing color to gray value 

Description 

void cpdf_setgray_stroke(int pdf document, double gray value); 

The cpdf_setgray_stroke() function sets the current drawing color to the given gray value. 

See also cpdf_setrgbcolor_stroke() . 

Prev Home Next 

cpdf_setgray_fill U^ cpdf_setgray 



PHP Manual 

Prev Next 



cpdf_setgray 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setgray ~ Sets drawing and fining color to gray value 

Description 

void cpdf_setgray(int pdf document, double gray value); 

The cpdf_setgray_stroke() function sets the current drawing and filling color to the given gray 
value. 

See also cpdf_setrgbcolor_stroke() , cpdf_setrgbcolor_fill() . 

Prev Home Next 

cpdf_setgray_stroke U^ cpdf_setrgbcolor_fill 



PHP Manual 

Prev Next 



cpdf_setrgbcolor_fill 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setrgbcolor_fill — Sets fining color to rgb color value 

Description 

void cpdf_set rgbcolor_f ill(int pdf document, double red value, double green value, 
double blue value); 

The cpdf_setrgbcolor_fill() function sets the current rgb color value to fill a path. 

See also cpdf_setrgbcolor_stroke() , cpdf_setrgbcolor () . 

Prev Home Next 

cpdf_setgray Ug cpdf_setrgbcolor_stroke 



PHP Manual 

Prev Next 



cpdf_setrgbcolor_stroke 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



cpdf_setrgbcolor_stroke ~ Sets drawing color to rgb color value 

Description 

void cpdf_set rgbcolor_st roke(int pdf document, double red value, double green value, 
double blue value); 

The cpdf_setrgbcolor_stroke() function sets the current drawing color to the given rgb color 
value. 

See also cpdf_setrgbcolor_fill() , cpdf_setrgbcolor() . 

Prev Home Next 

cpdf_setrgbcolor_fill Up cpdf_setrgbcolor 



PHP Manual 

Prev Next 



cpdf_setrgbcolor 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_setrgbcolor — Sets drawing and filHng color to rgb color value 

Description 

void cpdf_set rgbcolor(int pdf document, double red value, double green value, double 
blue value); 

The cpdf_setrgbcolor_stroke() function sets the current drawing and filling color to the given rgb 
color value. 

See also cpdf_setrgbcolor_stroke() , cpdf_setrgbcolor_fill() . 

Prev Home Next 

cpdf_setrgbcolor_stroke U^ cpdf_add_outline 



PHP Manual 

Prev Next 



cpdf_add_outline 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_add_outHne ~ Adds bookmark for current page 

Description 



void cpdf_add_out line(int pdf document, string text); 

The cpdf_add_outline() function adds a bookmark with text text that points to the current page. 

Example 1. Adding a page outline 

<?php 

$cpdf = cpdf_open ( ) ; 

cpdf_page_init ($cpdf , 1, 0, 595, 842); 

cpdf_add_outline ($cpdf , 0, 0, 0, 1, "Page 1"); 

// ... 

// some drawing 

// ... 

cpdf_f inalize ($cpdf ) ; 

Header ( "Content-type : application/pdf " ) ; 

cpdf_output_buf f er ($cpdf ) ; 

cpdf_close ($cpdf ) ; 

?> 



Prev Home Next 

cpdf_setrgbcolor Up cpdf_set_page_animation 



PHP Manual 

Prev Next 



cpdf_set_page_animation 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_set_page_animation ~ Sets duration between pages 

Description 

void cpdf_set_page_animat ion(int pdf document, int transition, double duration); 
The cpdf_set_page_animation() function set the transition between following pages. 

The value of transition can be 

for none, 

1 for two lines sweeping across the screen reveal the page, 

2 for multiple lines sweeping across the screen reveal the page, 

3 for a box reveals the page, 

4 for a single line sweeping across the screen reveals the page, 

5 for the old page dissolves to reveal the page, 

6 for the dissolve effect moves from one screen edge to another, 

7 for the old page is simply replaced by the new page (default) 

The value of duration is the number of seconds between page flipping. 

Prev Home Next 

cpdf_add_outline Up cpdf_importJpeg 



PHP Manual 

Prev Next 



cpdfjmportjpeg 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_importJpeg ~ Opens a JPEG image 

Description 



int cpdf _open_ jpeg(int pdf document, string file name, double x-koor, double y-koor, 
double angle, double width, double height, double x-scale, double y-scale, int mode); 

The cpdMmportJpegO function opens an image stored in the file with the name file name. 
The format of the image has to be jpeg. The image is placed on the current page at position 
(x-koor, y-koor). The image is rotated by angle degres. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdf_place_inline_image() , 

Prev Home Next 

cpdf_set_page_animation U^ cpdf_place_inline_image 



PHP Manual 

Prev Next 



cpdf_place_inline_image 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_place_inHne_image ~ Places an image on the page 

Description 

void cpdf_place_inline_image(int pdf document, int image, double x-koor, double 
y-koor, double angle, double width, double height, int mode); 

The cpdf_place_inline_image() function places an image created with the php image functions on 
the page at postion (x-koor, y-koor). The image can be scaled at the same time. 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

See also cpdMmportJpegQ , 

Prev Home Next 

cpdf_importJpeg U^ cpdf_add_annotation 



PHP Manual 

Prev Next 



cpdf_add_annotation 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

cpdf_add_annotation — Adds annotation 

Description 



void cpdf_add_annotat ion(int pdf document, double llx, double lly, double urx, double 
ury, string title, string content, int mode); 

The cpdf_add_annotation() adds a note with the lower left corner at (llx, lly) and the upper 
right corner at (urx, ury). 

The last optional parameter determines the unit length. If is or omitted the default unit as 
specified for the page is used. Otherwise the koodinates are measured in postscript points 
disregarding the current unit. 

Prev Home Next 

cpdf_place_inline_image Up Compression functions 



PHP Manual 

Prev Next 



gzclose 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzclose ~ close an open gz-file pointer 

Description 



int gzclose(int zp); 

The gz-file pointed to by zp is closed. 

Returns true on success and false on failure. 

The gz-file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

Prev Home Next 

Compression functions Up gzeof 



PHP Manual 

Prev Next 



gzeof 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzeof ~ test for end-of-file on a gz-file pointer 

Description 

int gzeof(int zp); 

Returns true if the gz-file pointer is at EOF or an error occurs; otherwise returns false. 

The gz-file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

Prev Home Next 

gzclose U^ gzfile 



PHP Manual 

Prev Next 



gzfile 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzfile ~ read entire gz-file into an array 

Description 

array gzf ile(string filename, int [use_include_path]); 

Identical to readgzfileQ , except that gzfile() returns the file in an array. 

You can use the optional second parameter and set it to "1", if you want to search for the file in the 
include_path , too. 

See also readgzfileQ , and gzopenQ . 

Prev Home Next 

gzeof Up gzgetc 



PHP Manual 

Prev Next 



gzgetc 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzgetc ~ get character from gz-file pointer 

Description 

string gzgetc(int zp); 

Returns a string containing a single (uncompressed) character read from the file pointed to by zp. 
Returns FALSE on EOF (as does gzeofQ ). 

The gz-file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

See also gzopenQ , and gzgetsQ . 

Prev Home Next 

gzfile Up gzgets 



PHP Manual 

Prev Next 



gzgets 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gzgets ~ get Hne from file pointer 

Description 

string gzgets(int zp, int length); 

Returns a (uncompressed) string of up to length - 1 bytes read from the file pointed to by fp. 
Reading ends when length - 1 bytes have been read, on a newline, or on EOF (whichever comes 
first). 

If an error occurs, returns false. 

The file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

See also gzopenQ , gzgetcQ , and fgetsQ . 

Prev Home Next 

gzgetc U^ gzgetss 



PHP Manual 

Prev Next 



gzgetss 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzgetss ~ get Hne from gz-file pointer and strip HTML tags 

Description 

string gzget ss(int zp, int length, string [allowable_tags]); 

Identical to gzgetsQ , except that gzgetss attempts to strip any HTML and PHP tags from the text it 
reads. 

You can use the optional third parameter to specify tags which should not be stripped. 

Note: allowable_tags was added in PHP 3.0.13, PHP4B3. 

See also gzgetsQ , gzopenQ , and strip_tags() . 

Prev Home Next 

gzgets U^ gzopen 



PHP Manual 

Prev Next 



gzopen 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gzopen — open gz-file 

Description 

int gzopen(string filename, string mode, int [use_include_path]); 

Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopenQ ("rb" or "wb") 

but can also include a compression level ("wb9") or a strategy: T for filtered data as in "wb6f", 'h' 
for Huffman only compression as in "wblh". (See the description of deflatelnit2 in zlib.h for more 
information about the strategy parameter.) 

Gzopen can be used to read a file which is not in gzip format; in this case gzreadQ will directly 
read from the file without decompression. 

Gzopen returns a file pointer to the file opened, after that, everything you read from this file 
descriptor will be transparently decompressed and what you write gets compressed. 

If the open fails, the function returns false. 

You can use the optional third parameter and set it to "1", if you want to search for the file in the 
include_path , too. 

Example 1. gzopen() example 

$fp = gzopen (" /tmp/file . gz" , "r"); 

See also gzcloseQ . 

Prev Home Next 

gzgetss Up gzpassthru 



PHP Manual 

Prev Next 



gzpassthru 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzpassthru ~ output all remaining data on a gz-file pointer 

Description 

int gzpassthru(int zp); 

Reads to EOF on the given gz-file pointer and writes the (uncompressed) results to standard output. 

If an error occurs, returns false. 

The file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

The gz-file is closed when gzpassthru() is done reading it (leaving zp useless). 

Prev Home Next 

gzopen Up gzputs 



PHP Manual 

Prev Next 



gzputs 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gzputs ~ write to a gz-file pointer 

Description 

int gzputs(int zp, string str, int [length]); 

gzputsO is an ahas to gzwriteQ , and is identical in every way. 

Prev Home Next 

gzpassthru Up gzread 



PHP Manual 

Prev Next 



gzread 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gzread ~ Binary-safe gz-file read 

Description 

string gzread(int zp, int length); 

gzreadO reads up to length bytes from the gz-file pointer referenced by zp. Reading stops when 
length (uncompressed) bytes have been read or EOF is reached, whichever comes first. 

// get contents of a gz-file into a string 
$filename = " /usr/local/something . txt . gz " ; 
$zd = gzopen ( $filename, "r" ); 
$contents = gzread( $zd, 10000 ); 
gzclose ( $zd ) ; 

See also gzwriteQ , gzopenQ , gzgetsQ , gzgetssQ , gzfileQ , and gzpassthruQ . 

Prev Home Next 

gzputs Up gzrewind 



PHP Manual 

Prev Next 



gzrewind 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gzrewind ~ rewind the position of a gz-file pointer 

Description 



int gzrewind(int zp); 

Sets the file position indicator for zp to the beginning of the file stream. 

If an error occurs, returns 0. 

The file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

See also gzseekQ and gztellQ . 

Prev Home Next 

gzread U^ gzseek 



PHP Manual 

Prev Next 



gzseek 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gzseek ~ seek on a gz-file pointer 

Description 

int gzseek(int zp, int offset); 

Sets the file position indicator for the file referenced by zp to offset bytes into the file stream. 
Equivalent to calling (in C) gzseek ( zp, offset, SEEK_SET ). 

If the file is opened for reading, this function is emulated but can be extremely slow. If the file is 
opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes 
up to the new starting position. 

Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an 
error. 

See also gztellQ and gzrewindQ . 

Prev Home Next 

gzrewind Up gztell 



PHP Manual 

Prev Next 



gztell 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gztell ~ tell gz-file pointer read/write position 

Description 



int gztell(int zp); 

Returns the position of the file pointer referenced by zp; i.e., its offset into the file stream. 

If an error occurs, returns false. 

The file pointer must be valid, and must point to a file successfully opened by gzopenQ . 

See also gzopenQ , gzseekQ and gzrewindQ . 

Prev Home Next 

gzseek Ug gzwrite 



PHP Manual 

Prev Next 



gzwrite 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



gzwrite ~ Binary-safe gz-file write 

Description 

int gzwrite(int zp, string string, int [length]); 

gzwriteO writes the contents of string to the gz-file stream pointed to by zp. If the length 
argument is given, writing will stop after length (uncompressed) bytes have been written or the 
end of string is reached, whichever comes first. 

Note that if the length argument is given, then the magic_quotes_runtime configuration option 
will be ignored and no slashes will be stripped from string. 

See also gzreadQ , gzopenQ , and gzputsQ . 

Prev Home Next 

gztell Up readgzfile 



PHP Manual 

Prev Next 



readgzfile 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



readgzfile ~ output a gz-file 

Description 

int readgzf ile(string filename, int [use_include_path]); 

Reads a file, decompresses it and writes it to standard output. 

ReadgzfileO can be used to read a file which is not in gzip format; in this case readgzfile() will 
directly read from the file without decompression. 

Returns the number of (uncompressed) bytes read from the file. If an error occurs, false is returned 
and unless the function was called as ©readgzfile, an error message is printed. 

The file filename will be opened from the filesystem and its contents written to standard output. 

You can use the optional second parameter and set it to " 1 ", if you want to search for the file in the 
include_path , too. 

See also gzpassthruQ , gzfileQ , and gzopenQ . 

Prev Home Next 

gzwrite Up Database (dbm-style) abstraction 

layer functions 



PHP Manual 

Prev Next 



dba close 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_close ~ Close database 

Description 

void db a_c 1 o s e (int handle) ; 

dba_dose() closes the established database and frees all resources specified by handle. 

handle is a database handle returned by dba_open(). 

dba_dose() does not return any value. 

See also: dba_open() dba_popen() 

Prev Home Next 

Database (dbm-style) abstraction Up dba_delete 

layer functions 



PHP Manual 

Prev Next 



dba_delete 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dba_delete ~ Delete entry specified by key 

Description 

string db a_de 1 e t e (string key, int handle) ; 

dba_delete() deletes the entry specified by icey from the database specified with handle. 

key is the key of the entry which is deleted. 

handle is a database handle returned by dba_open(). 

dba_delete() returns true or false, if the entry is deleted or not deleted, respectively. 

See also: dba_exists() dba_fetch() dba_insert() dba_replace() 

Prev Home Next 

dba_close Up dba_exists 



PHP Manual 

Prev Next 



dba_exists 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dba_exists ~ Check whether key exists 

Description 

b o o 1 db a_e x i s t s (string key, int handle) ; 

dba_exists() checks whether the specified icey exists in the database specified by handle. 

key is the key the check is performed for. 

handle is a database handle returned by dba_open(). 

dba_exists() returns true or false, if the key is found or not found, respectively. 

See also: dba_fetch() dba_delete() dba_insert() dba_replace() 

Prev Home Next 

dba_delete Up dba_fetch 



PHP Manual 

Prev Next 



dba_fetch 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dba_fetch ~ Fetch data specified by key 

Description 

string dba_f etch(string key, int handle); 

dba_fetch() fetches the data specified by ^ey from the database specified with handle. 

key is the key the data is specified by. 

handle is a database handle returned by dba_open(). 

dba_fetch() returns the associated string or false, if the key/data pair is found or not found, 
respectively. 

See also: dba_exists() dba_delete() dba_insert() dba_replace() 

Prev Home Next 

dba_exists Ug dba_firstkey 



PHP Manual 

Prev Next 



dba_firstkey 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_firstkey ~ Fetch first key 

Description 

string dba_f irst key (int handle); 

dba_firstkey() returns the first key of the database specified by handle and resets the internal key 
pointer. This permits a linear search through the whole database. 

handle is a database handle returned by dba_open(). 

dba_firstkey() returns the key or false depending on whether it succeeds or fails, respectively. 

See also: dba_nextkey() 

Prev Home Next 

dba_fetch Up dba_insert 



PHP Manual 

Prev Next 



dba insert 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_insert ~ Insert entry 

Description 

bool dba_insert (string key, string value, int handle); 

dba_insert() inserts the entry described with key and value into the database specified by 
handle. It fails, if an entry with the same key already exists. 

key is the key of the entry to be inserted. 

value is the value to be inserted. 

handle is a database handle returned by dba_open(). 

dba_insert() returns true or false, depending on whether it succeeds of fails, respectively. 

See also: dba_exists() dba_delete() dba_fetch() dba_replace() 

Prev Home Next 

dba_firstkey Up dba_nextkey 



PHP Manual 

Prev Next 



dba_nextkey 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_nextkey ~ Fetch next key 

Description 

string dba_next key (int handle); 

dba_nextkey() returns the next key of the database specified by handle and increments the 
internal key pointer. 

handle is a database handle returned by dba_open(). 

dba_nextkey() returns the key or false depending on whether it succeeds or fails, respectively. 

See also: dba_firstkey() 

Prev Home Next 

dba_insert Up dba_popen 



PHP Manual 

Prev Next 



dba_popen 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dba_popen ~ Open database persistently 

Description 

int dba_p op en (string path, string mode, string handler, [...]); 

dba_popen() establishes a persistent database instance for path with mode using handler. 

path is commonly a regular path in your filesystem. 

mode is "r" for read access, "w" for read/write access to an already existing database, "c" for 
read/write access and database creation if it doesn't currently exist, and "n" for create, truncate and 
read/write access. 

handler is the name of the handler which shall be used for accessing path. It is passed all 
optional parameters given to dba_popen() and can act on behalf of them. 

dba_popen() returns a positive handler id or false, in the case the open is successful or fails, 
respectively. 

See also: dba_open() dba_close() 

Prev Home Next 

dba_nextkey U^ dba_open 



PHP Manual 

Prev Next 



dba_open 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_open ~ Open database 

Description 

int dba_open(string path, string mode, string handler, [...]); 

dba_open() estabhshes a database instance for path with mode using handler. 

path is commonly a regular path in your filesystem. 

mode is "r" for read access, "w" for read/write access to an already existing database, "c" for 
read/write access and database creation if it doesn't currently exist, and "n" for create, truncate and 
read/write access. 

handler is the name of the handler which shall be used for accessing path. It is passed all 
optional parameters given to dba_open() and can act on behalf of them. 

dba_open() returns a positive handler id or false, in the case the open is successful or fails, 
respectively. 

See also: dba_popen() dba_close() 

Prev Home Next 

dba_popen Ug dba_optimize 



PHP Manual 

Prev Next 



dba_optimize 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_optimize ~ Optimize database 

Description 

bool dba_optimize(int handle); 

dba_optimize() optimizes the underlying database specified by handle. 

handle is a database handle returned by dba_open(). 

dba_optimize() returns true or false, if the optimization succeeds or fails, respectively. 

See also: dba_sync() 

Prev Home Next 

dba_open Ug dba_replace 



PHP Manual 

Prev Next 



dba_replace 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dba_replace ~ Replace or insert entry 

Description 

bool dba_replace(string key, string value, int handle); 

dba_replace() replaces or inserts the entry described with key and value into the database 
specified by handle. 

key is the key of the entry to be inserted. 

value is the value to be inserted. 

handle is a database handle returned by dba_open(). 

dba_replace() returns true or false, depending on whether it succeeds of fails, respectively. 

See also: dba_exists() dba_delete() dba_fetch() dba_insert() 

Prev Home Next 

dba_optimize Up dba_sync 



PHP Manual 

Prev Next 



dba_sync 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dba_sync ~ Synchronize database 

Description 

bool dba_sync(int handle); 

dba_sync() synchronizes the database specified by handle. This will probably trigger a physical 
write to disk, if supported. 

handle is a database handle returned by dba_open(). 

dba_sync() returns true or false, if the synchronization succeeds or fails, respectively. 

See also: dba_optimize() 

Prev Home Next 

dba_replace Up Date and Time functions 



PHP Manual 

Prev Next 



checkdate 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



checkdate ~ vaUdate a date/time 

Description 

int checkdate(int month, int day, int year); 

Returns true if the date given is vahd; otherwise returns false. Checks the vaUdity of the date 
formed by the arguments. A date is considered vahd if: 

q year is between and 32767 inclusive 

q month is between 1 and 12 inclusive 

q day is within the allowed number of days for the given month. Leap years are taken into 
consideration. 

Prev Home Next 

Date and Time functions Up date 



PHP Manual 

Prev Next 



getdate 

getdate ~ get date/time information 

Description 

array getdate(int timestamp); 

Returns an associative array containing the date information of the timestamp as the following array 
elements: 



'seconds" - seconds 

'minutes" - minutes 

'hours" - hours 

'mday" - day of the month 

'wday" - day of the week, numeric 

'mon" - month, numeric 

'year" - year, numeric 

'yday" - day of the year, numeric; i.e. "299" 

'weekday" - day of the week, textual, full; i.e. "Friday" 



q "month" - month, textual, full; i.e. "January" 

Prev Home Next 

date Up gettimeofday 



PHP Manual 

Prev Next 



gettimeofday 

gettimeofday ~ get current time 

Description 

array gettimeof day(void); 

This is an interface to gettimeofday(2). It returns an associative array containing the data returned 
from the system call. 

q "sec" - seconds 

q "usee" - microseconds 

q "minuteswest" - minutes west of Greenwich 

q "dsttime" - type of dst correction 

Prev Home Next 

getdate Ug gmdate 



PHP Manual 

Prev Next 



gmdate 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gmdate ~ format a GMT/CUT date/time 

Description 

string gmdate (string format, int timestamp); 

Identical to the dateQ function except that the time returned is Greenwich Mean Time (GMT). For 
example, when run in Finland (GMT +0200), the first line below prints "Jan 01 1998 00:00:00", 
while the second prints "Dec 31 1997 22:00:00". 

Example 1. gmdate() example 

echo date ( "M d Y H : i : s" , mktime ( 0, 0, 0, 1, 1, 1998 ) ); 
echo gmdate ( "M d Y H : i : s" , mktime ( 0, 0, 0, 1, 1, 1998 ) ); 

See also dateQ , mktimeQ and gmmktimeQ . 

Prev Home Next 

gettimeofday U^ gmmktime 



PHP Manual 

Prev Next 



gmmktime 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

gmmktime ~ get UNIX timestamp for a GMT date 

Description 

int gmmktime(int hour, int minute, int second, int month, int day, int year, int [is_dst]); 
Identical to mktimeQ except the passed parameters represents a GMT date. 

Prev Home Next 

gmdate Up gmstrftime 



PHP Manual 

Prev Next 



gmstrftime 

gmstrftime ~ format a GMT/CUT time/date according to locale settings 

Description 

string gmstrftime (string format, int timestamp) ; 

Behaves the same as strftimeQ except that the time returned is Greenwich Mean Time (GMT). For 
example, when run in Eastern Standard Time (GMT -0500), the first line below prints "Dec 31 1998 
20:00:00", while the second prints "Jan 01 1999 01:00:00". 

Example 1. gmstrftime() example 

setlocale ( ' LC_TIME ' , ' en_US ' ) ; 

echo strftime ("%b %d %Y %H : %M: %S" , mktime (20, 0, 0, 12, 31, 98 ) ) . " \n" ; 

echo gmstrftime ("%b %d %Y %H : %M: %S" , mktime (20, 0, 0, 12, 31, 98 ) ) . "\n" ; 

See also strftimeQ . 

Prev Home Next 

gmmktime Ug microtime 



PHP Manual 

Prev Next 



dbase_create 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_create ~ creates a dBase database 

Description 

int dbase_create(string filename, array fields); 

The fields parameter is an array of arrays, each array describing the format of one field in the 
database. Each field consists of a name, a character indicating the field type, a length, and a 
precision. 

The types of fields available are: 
L 

Boolean. These do not have a length or precision. 
M 

Memo. (Note that these aren't supported by PHP.) These do not have a length or precision. 
D 

Date (stored as YYYYMMDD). These do not have a length or precision. 

N 

Number. These have both a length and a precision (the number of digits after the decimal 
point). 

C 

String. 
If the database is successfully created, a dbase_identifier is returned, otherwise false is returned. 



Example 1. Creating a dBase database file 

// "database" name 
$dbname = " /tmp/test . dbf " ; 

// database "definition" 

$def = 

array ( 

array ("date", "D") , 
array ("name", "C", 50), 
array ("age", "N", 3, 0), 
array ("email", "C", 128), 
array ( "ismember" , "L") 

); 

// creation 

if ( ! dbase_create ( $dbname, $def ) ) 

print "<strong>Error!</strong>"; 



Prev Home Next 

dBase functions Ug dbase_open 



PHP Manual 

Prev Next 



dbase_open 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_open — opens a dBase database 

Description 

int dbase_open(string filename, int flags); 

The flags correspond to those for the open() system call. (Typically means read-only, 1 means 
write-only, and 2 means read and write.) 

Returns a dbase_identifier for the opened database, or false if the database couldn't be opened. 

Prev Home Next 

dbase_create U^ dbase_close 



PHP Manual 

Prev Next 



dbase_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_close ~ close a dBase database 

Description 

bool dbase_close(int dbase_identifier) ; 

Closes the database associated with dbase_identifier. 

Prev Home Next 

dbase_open Up dbase_pack 



PHP Manual 

Prev Next 



dbase_pack 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_pack ~ packs a dBase database 

Description 

bool dbase_pack (int dbase_identifier) ; 

Packs the specified database (permanently deleting all records marked for deletion using 
dbase_delete_record() . 

Prev Home Next 

dbase_close Up dbase_add_record 



PHP Manual 

Prev Next 



dbase_add_record 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_add_record ~ add a record to a dBase database 

Description 

b o o 1 db a s e_a dd_r e c o r d(int dbase_identifier, array record) ; 

Adds the data in the record to the database. If the number of items in the suppHed record isn't 
equal to the number of fields in the database, the operation will fail and false will be returned. 

Prev Home Next 

dbase_pack Up dbase_replace_record 



PHP Manual 

Prev Next 



dbase_replace_record 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_replace_record ~ replace a record in a dBase database 

Description 

bool dbase_replace_record(int dbase_identifier, array record, int dbase_record_number); 

Replaces the data associated with the record record_number with the data in the record in the 
database. If the number of items in the supplied record is not equal to the number of fields in the 
database, the operation will fail and false will be returned. 

dbase_record_number is an integer which spans from 1 to the number of records in the 
database (as returned by dbase_numrecords() ) . 

Prev Home Next 

dbase_add_record Up dbase_delete_record 



PHP Manual 

Prev Next 



dbase delete record 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_delete_record ~ deletes a record from a dBase database 

Description 

b o o 1 db a s e_de let e_r e c o r d(int dbase_identifier, int record) ; 

Marks record to be deleted from the database. To actually remove the record from the database, 
you must also call dbase_pack() . 

Prev Home Next 

dbase_replace_record Up dbase_get_record 



PHP Manual 

Prev Next 



dbase_get_record 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_get_record ~ gets a record from a dBase database 

Description 

array dbase_get_record(int dbase_identifier, int record); 

Returns the data from record in an array. The array is indexed starting at 0, and includes an 
associative member named 'deleted' which is set to 1 if the record has been marked for deletion (see 
dbase_delete_record() . 

Each field is converted to the appropriate PHP type. (Dates are left as strings.) 

Prev Home Next 

dbase_delete_record Up dbase_get_record_with_names 



PHP Manual 

Prev Next 



dbase_get_record_with_names 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dbase_get_record_with_names ~ gets a record from a dBase database as an associative array 

Description 

array dbase_get_record_with_names(int dbase_identifier, int record); 

Returns the data from record in an associative array. The array also includes an associative 
member named 'deleted' which is set to 1 if the record has been marked for deletion (see 
dbase_delete_record() . 

Each field is converted to the appropriate PHP type. (Dates are left as strings.) 

Prev Home Next 

dbase_get_record Up dbase_numfields 



PHP Manual 

Prev Next 



dbase_numfields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_numfields ~ find out how many fields are in a dBase database 

Description 

int dbase_numf ields(int dbase_identifier); 

Returns the number of fields (columns) in the specified database. Field numbers are between and 
dbase_numfields($db)-l, while record numbers are between 1 and dbase_numrecords($db). 

Example 1. Using dbase_numfields() 

$rec = dbase_get_record ( $db, $recno) ; 
$nf = dbase_numf ields ($db) ; 
for ($i=0; $i < $nf; $i++) { 
print $rec [$i] . "<br>\n" ; 
} 

Prev Home Next 

dbase_get_record_with_names Up dbase_numrecords 



PHP Manual 

Prev Next 



dbase numrecords 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbase_numrecords ~ find out how many records are in a dBase database 

Description 

int dbase_numrecords(int dbase_identifier); 

Returns the number of records (rows) in the specified database. Record numbers are between 1 and 
dbase_numrecords($db), while field numbers are between and dbase_numfields($db)-l. 

Prev Home Next 

dbase_numfields Up dbm functions 



PHP Manual 

Prev Next 



dbmopen 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



dbmopen ~ opens a dbm database 

Description 

int dbmopen (string filename, string flags); 

The first argument is the full-path filename of the dbm file to be opened and the second is the file 
open mode which is one of "r", "n", "c" or "w" for read-only, new (implies read- write, and most 
likely will truncate an already-existing database of the same name), create (implies read-write, and 
will not truncate an already-existing database of the same name) and read-write respectively. 

Returns an identifer to be passed to the other dbm functions on success, or false on failure. 

If ndbm support is used, ndbm will actually create filename.dir and filename. pag files, gdbm only 
uses one file, as does the internal flat-file support, and Berkeley db creates a filename. db file. Note 
that PHP does its own file locking in addition to any file locking that may be done by the dbm 
library itself. PHP does not delete the .Ick files it creates. It uses these files simply as fixed inodes 
on which to do the file locking. For more information on dbm files, see your Unix man pages, or 
obtain GNU's gdbm from ftp : //prep . ai .mit . edu/pub/gnu. 

Prev Home Next 

dbm functions Up dbmclose 



PHP Manual 

Prev Next 



dbmclose 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmclose ~ closes a dbm database 

Description 

bool dbmclose(int dbm_identifier); 
Unlocks and closes the specified database. 

Prev Home Next 

dbmopen Up dbmexists 



PHP Manual 

Prev Next 



dbmexists 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmexists ~ tells if a value exists for a key in a dbm database 

Description 

bool dbmexi s t s(int dbm_identifier, string key); 
Returns true if there is a value associated with the key. 

Prev Home Next 

dbmclose Up dbmfetch 



PHP Manual 

Prev Next 



dbmfetch 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmfetch — fetches a value for a key from a dbm database 

Description 

string dbmf etch(int dbm_identifier, string key); 
Returns the value associated with key. 



Prev Home Next 

dbmexists Up dbminsert 



PHP Manual 

Prev Next 



dbminsert 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbminsert ~ inserts a value for a key in a dbm database 

Description 

int dbminsert (int dbm_identifier, string key, string value); 

Adds the value to the database with the specified key. 

Returns -1 if the database was opened read-only, if the insert was successful, and 1 if the 
specified key already exists. (To replace the value, use dbmreplaceQ .) 

Prev Home Next 

dbmfetch U^ dbmreplace 



PHP Manual 

Prev Next 



dbmreplace 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmreplace ~ replaces the value for a key in a dbm database 

Description 

bool dbmreplace(int dbm_identifier, string key, string value); 

Replaces the value for the specified key in the database. 

This will also add the key to the database if it didn't already exist. 

Prev Home Next 

dbminsert U^ dbmdelete 



PHP Manual 

Prev Next 



dbmdelete 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmdelete ~ deletes the value for a key from a dbm database 

Description 

bool dbmdelete(int dbm_identifier, string key); 
Deletes the value for key in the database. 
Returns false if the key didn't exist in the database. 

Prev Home Next 

dbmreplace U^ dbmfirstkey 



PHP Manual 

Prev Next 



dbmfirstkey 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmfirstkey ~ retrieves the first key from a dbm database 

Description 

string dbmf irstkey(int dbm_identifier); 

Returns the first key in the database. Note that no particular order is guaranteed since the database 
may be built using a hash-table, which doesn't guarantee any ordering. 

Prev Home Next 

dbmdelete Up dbmnextkey 



PHP Manual 

Prev Next 



dbmnextkey 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbmnextkey ~ retrieves the next key from a dbm database 

Description 

string dbmnextkey(int dbm_identifier, string key); 

Returns the next key after key. By calhng dbmfirstkeyQ followed by successive calls to 
dbmnextkeyO it is possible to visit every key/value pair in the dbm database. For example: 
Example 1. Visiting every key/value pair in a dbm database. 

$key = dbmf irstkey ( $dbm_id) ; 
while ($key) { 

echo "$key = " . dbmf etch ( $dbm_id, $key) . "\n"; 

$key = dbmnextkey ($dbm_id, $key) ; 
} 



Prev Home Next 

dbmfirstkey Ug dblist 



PHP Manual 

Prev Next 



dblist 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

dbhst ~ describes the dbm-compatible Hbrary being used 

Description 

string dblist(void); 



Prev Home Next 

dbmnextkey U^ Directory functions 



PHP Manual 

Prev Next 



chdir 

chdir ~ change directory 

Description 

int chdir( string directory) ; 

Changes PHP's current directory to directory. Returns FALSE if unable to change directory, 
TRUE otherwise. 

Prev Home Next 

Directory functions U^ dir 



PHP Manual 

Prev Next 



dir 

dir ~ directory class 

Description 

new d i r ( string directory) ; 

A pseudo-object oriented mechanism for reading a directory. The given directoryis opened. 
Two properties are available once directory has been opened. The handle property can be used with 
other directory functions such as readdirQ , rewinddirQ and closedirQ . The path property is set to 

path the directory that was opened. Three methods are available: read, rewind and close. 

Example 1. Dir() Example 

$d = dir ("/etc") ; 

echo "Handle: " . $d->handle . "<br>\n" ; 
echo "Path: " . $d->path . "<br>\n" ; 
while ( $entry=$d->read () ) { 
echo $entry . "<br>\n" ; 

} 

$d->close ( ) ; 



Prev Home Next 

chdir U^ closedir 



PHP Manual 

Prev Next 



closedir 

closedir ~ close directory handle 

Description 

void closedir(int dir_handle); 

Closes the directory stream indicated by dir_handle. The stream must have previously been 
opened by opendirQ . 

Prev Home Next 

dir Up opendir 



PHP Manual 

Prev Next 



opendir 

opendir — open directory handle 

Description 



int opendir (string path); 

Returns a directory handle to be used in subsequent closedirQ , readdirQ , and rewinddirQ calls. 

Prev Home Next 

closedir U^ readdir 



PHP Manual 

Prev Next 



filepro 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro ~ read and verify the map file 

Description 

bool filepro( string directory) ; 

This reads and verifies the map file, storing the field count and info. 

No locking is done, so you should avoid modifying your filePro database while it may be opened in 
PHP. 

Prev Home Next 

filePro functions U^ filepro_fieldname 



PHP Manual 

Prev Next 



filepro_fieldname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro_fieldname ~ gets the name of a field 

Description 

string f ilepro_f ieldname(int field_number); 

Returns the name of the field corresponding to field_number. 

Prev Home Next 

filepro Up filepro_fieldtype 



PHP Manual 

Prev Next 



filepro_fieldtype 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro_fieldtype ~ gets the type of a field 

Description 

string filepr o_f i e 1 dt yp e (int field_number) ; 

Returns the edit type of the field corresponding to field_number. 

Prev Home Next 

filepro_fieldname Up filepro_fieldwidth 



PHP Manual 

Prev Next 



filepro_fieldwidth 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro_fieldwidth — gets the width of a field 

Description 

int f ilepro_f ieldwidth(int field_number); 

Returns the width of the field corresponding to field_number. 

Prev Home Next 

filepro_fieldtype Up filepro_retrieve 



PHP Manual 

Prev Next 



filepro_retrieve 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro_retrieve ~ retrieves data from a filePro database 

Description 

string filepr o_r e t r i e v e (int row_number, int f ield_number) ; 
Returns the data from the specified location in the database. 

Prev Home Next 

filepro_fieldwidth Up filepro_fieldcount 



PHP Manual 

Prev Next 



filepro_fieldcount 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

filepro_fieldcount ~ find out how many fields are in a filePro database 

Description 

int f ilepro_f ieldcount(void); 

Returns the number of fields (columns) in the opened filePro database. 

See also fileproQ . 

Prev Home Next 

filepro_retrieve U^ filepro_rowcount 



PHP Manual 

Prev Next 



fdf_open 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



fdf_open ~ Open a FDF document 

Description 

int f df_open(string filename); 

The fdf_open() function opens a file with form data. This file must contain the data as returned 
from a PDF form. Currently, the file has to be created 'manually' by using fopenQ and writing the 
content of HTTP_FDF_DATA with fwriteQ into it. A mechanism like for HTML form data where 
for each input field a variable is created does not exist. 
Example 1. Accessing the form data 

<?php 

// Save the FDF data into a temp file 

$fdffp = fopenC'test.fdf ", "w"); 

fwrite ($fdf fp, $HTTP_FDF_DATA, strlen ($HTTP_FDF_DATA) ) ; 

fclose ($fdf fp) ; 

// Open temp file and evaluate data 
$fdf = fdf_open("test.fdf ") ; 

fdf_close ($fdf ) ; 
?> 

See also fdf_close() . 

Prev Home Next 

Forms Data Format functions U^ fdf_close 



PHP Manual 

Prev Next 



fdf_create 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_create ~ Create a new FDF document 

Description 

int f df_create(void ); 

The fdf_create() creates a new FDF document. This function is needed if one would hke to 
populate input fields in a PDF document with data. 

Example 1. Populating a PDF document 

<?php 

$outfdf = f df_create ( ) ; 

f df_set_value ( $outf df , "volume", $volume, 0); 

fdf_set_file ($outfdf , "http : /test fdf /result label .pdf" ) ; 

fdf_save ($outfdf , "outtest . f df " ) ; 

fdf_close ($outfdf ) ; 

Header ( "Content-type : application/vnd. fdf" ) ; 

$fp = f open ("outtest .fdf ", "r"); 

fpassthru ( $fp) ; 

unlink ( "outtest . fdf" ) ; 

?> 

See also fdf_close() , fdf_save() , fdf_open() . 

Prev Home Next 

fdf_close Up fdf_save 



PHP Manual 

Prev Next 



fdf set value 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_set_value ~ Set the value of a field 

Description 

void f df_set_value(int fdf_document, string fieldname, string value, int isName); 

The fdf_set_value() function sets the value of a field. The last parameter determines if the field 
value is to be converted to a PDF Name (isName - 1) or set to a PDF String (isName - 0). 

See also fdf_get_value() . 

Prev Home Next 

fdf_get_value U^ fdf_next_field_name 



PHP Manual 

Prev Next 



fdf set file 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_set_file ~ Set the value of the /F key 

Description 

void f df_set_f ile(int fdf_document, string filename); 

The fdf_set_file() sets the value of the /F key. The /F key is just a reference to a PDF form which is 
to be populated with data. In a web environment it is a URL (e.g. http:/testfdf/resultlabel.pdf). 

See also fdf_get_file() and example for fdf_create() . 

Prev Home Next 

fdf_get_status Ug fdf_get_file 



PHP Manual 

Prev Next 



fdf_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_close ~ Close an FDF document 

Description 

void f df_close(int fdf_document); 

The fdf_close() function closes the FDF document. 

See also fdf_open() . 

Prev Home Next 

fdf_open Ug fdf_create 



PHP Manual 

Prev Next 



fdf save 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



fdf_save ~ Save a FDF document 

Description 

int fdf_save(string filename); 

The fdf_save() function saves a FDF document. The FDF Toolkit provides a way to output the 
document to stdout if the parameter filename is '.'. This does not work if PHP is used as an 
apache module. In such a case one will have to write to a file and use e.g. fpassthruQ . to output it. 

See also fdf_close() and example for fdf_create() . 

Prev Home Next 

fdf_create Ug fdf_get_value 



PHP Manual 

Prev Next 



fdf_get_value 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_get_value ~ Get the value of a field 

Description 

string f df_get_value(int fdf_document, string fieldname); 
The fdf_get_value() function returns the value of a field. 
See also fdf_set_value() . 

Prev Home Next 

fdf_save U^ fdf_set_value 



PHP Manual 

Prev Next 



fdf next field name 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_next_field_name ~ Get the next field name 

Description 

string f df_next_f ield_name(int fdf_document, string fieldname); 

The fdf_next_field_name() function returns the name of the field after the field in fieldname or 
the field name of the first field if the second paramter is NULL. 

See also fdf_set_field(), fdf_get_field(). 

Prev Home Next 

fdf_set_value U^ fdf_set_ap 



PHP Manual 

Prev Next 



fdf_set_ap 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_set_ap ~ Set the appearance of a field 

Description 

void f df_set_ap(int fdf_document, string field_name, int face, string filename, int 
page_number); 

The fdf_set_ap() function sets the appearance of a field (i.e. the value of the /AP key). The possible 
values of face are l=FDFNormalAP, 2=FDFRolloverAP, 3=FDFDownAP. 

Prev Home Next 

fdf_next_field_name Up fdf_set_status 



PHP Manual 

Prev Next 



fdf_set_status 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_set_status - Set the value of the /STATUS key 

Description 

void f df_set_status(int fdf_document, string status); 
The fdf_set_status() sets the value of the /STATUS key. 
See also fdf_get_status() . 

Prev Home Next 

fdf_set_ap U^ fdf_get_status 



PHP Manual 

Prev Next 



fdf_get_status 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_get_status -- Get the value of the /STATUS key 

Description 

string f df_get_status(int fdf_document); 

The fdf_get_status() returns the value of the /STATUS key. 

See also fdf_set_status() . 

Prev Home Next 

fdf_set_status U^ fdf_set_file 



PHP Manual 

Prev Next 



fdf_get_file 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

fdf_get_file ~ Get the value of the /F key 

Description 

string f df_get_f ile(int fdf_document); 
The fdf_set_file() returns the value of the /F key. 
See also fdf_set_file(). 



Prev Home Next 

fdf_set_file Ug FTP functions 



PHP Manual 

Prev Next 



ftp_connect 

ftp_connect ~ Opens up an FTP connection 

Description 

int f tp_connect(string host, int [port] ); 

Returns a FTP stream on success, false on error. 

ftp_connect() opens up a FTP connection to the specified host. The port parameter specifies an 
alternate port to connect to. If it is omitted or zero, then the default FTP port, 21, will be used. 

Prev Home Next 

FTP functions Up ftp_login 



PHP Manual 

Prev Next 



ftpjogin 

ftp_login ~ Logs in an FTP connection 

Description 



int f tp_login(int ftp_stream, string username, string password); 
Returns true on success, false on error. 
Logs in the given FTP stream. 

Prev Home Next 

ftp_connect Ug ftp_pwd 



PHP Manual 

Prev Next 



ftp_pwd 

ftp_pwd ~ Returns the current directory name 

Description 

int f tp_pwd(int ftp_stream); 

Returns the current directory, or false on error. 

Prev Home Next 

ftp_login Ug ftp_cdup 



PHP Manual 

Prev Next 



ftp_cdup 

ftp_cdup ~ Changes to the parent directory 

Description 

int f tp_cdup(int ftp_stream); 
Returns true on success, false on error. 
Changes to the parent directory. 

Prev Home Next 

ftp_pwd lj£ ftp_chdir 



PHP Manual 

Prev Next 



ftp_chdir 

ftp_chdir ~ Changes directories on a FTP server 

Description 

int f tp_chdir(int ftp_stream, string directory); 
Returns true on success, false on error. 
Changes to the specified directory. 

Prev Home Next 

ftp_cdup Up ftp_mkdir 



PHP Manual 

Prev Next 



ftp_mkdir 

ftp_mkdir — Creates a directory 

Description 



string f tp_mkdir(int ftp_stream, string directory); 

Returns tlie newly created directory name on success, false on error. 

Creates the specified directory. 

Prev Home Next 

ftp_chdir Up ftp_rmdir 



PHP Manual 

Prev Next 



ftp_rmdir 

ftp_rmdir ~ Removes a directory 

Description 

int f tp_rmdir(int ftp_stream, string directory); 
Returns true on success, false on error. 
Removes the specified directory. 

Prev Home Next 

ftp_mkdir Up ftp_nlist 



PHP Manual 

Prev Next 



ftp_nlist 

ftp_nlist ~ Returns a list of files in the given directory. 

Description 

i n t ft p_n 1 i s t (int ftp_stream, string directory) ; 
Returns an array of filenames on success, false on error. 

Prev Home Next 

ftp_rmdir Ug ftp_rawlist 



PHP Manual 

Prev Next 



ftp_rawlist 

ftp_rawlist ~ Returns a detailed list of files in the given directory. 

Description 

int f tp_rawlist(int ftp_stream, string directory); 

ftp_rawlist() executes the FTP LIST command, and returns the result as an array. Each array 
element corresponds to one line of text. The output is not parsed in any way. The system type 
identifier returned by ftp_systype() can be used to determine how the results should be interpreted. 

Prev Home Next 

ftp_nlist Up ftp_systype 



PHP Manual 

Prev Next 



ftp_systype 

ftp_systype ~ Returns the system type identifier of the remote FTP server. 

Description 

int ftp_systype(int ftp_stream); 

Returns the remote system type, or false on error. 

Prev Home Next 

ftp_rawHst U^ ftp_pasv 



PHP Manual 

Prev Next 



ftp_pasv 

ftp_pasv ~ Turns passive mode on or off. 

Description 

int f tp_pasv(int ftp_stream, int pasv); 

Returns true on success, false on error. 

ftp_pasv() turns on passive mode if the pas v parameter is true (it turns off passive mode if pasv 
is false.) In passive mode, data connections are initiated by the client, rather than by the server. 

Prev Home Next 

ftp_systype Up ftp_get 



PHP Manual 

Prev Next 



ftp_get 

ftp_get ~ Downloads a file from the FTP server. 

Description 

int f tp_get(int ftp_stream, string local_file, string remote_file, int mode); 

Returns true on success, false on error. 

ftp_get() retrieves remote_file from the FTP server, and saves it to local_flle locally. The 
transfer mode specified must be either FTP_ASCII or FTP_BINARY. 

Prev Home Next 

ftp_pasv Ug ftp_fget 



PHP Manual 

Prev Next 



ftpjget 

ftp_fget ~ Downloads a file from the FTP server and saves to an open file. 

Description 

int f tp_f get(int ftp_stream, int fp, string remote_file, int mode); 

Returns true on success, false on error. 

ftp_fget() retrieves remote_file from the FTP server, and writes it to the given file pointer, fp. 
The transfer mode specified must be either FTP_ASCII or FTP_BINARY. 

Prev Home Next 

ftp_get Ug ftp_put 



PHP Manual 

Prev Next 



ftp_put 

ftp_put ~ Uploads a file to the FTP server. 

Description 



int f tp_put(int ftp_stream, string remote_file, string local_file, int mode); 

Returns true on success, false on error. 

ftp_put() stores local_f He on the FTP server, as remote_file. The transfer mode 
specified must be either FTP_ASCII or FTP_BINARY. 

Prev Home Next 

ftp_fget Up ftp_fput 



PHP Manual 

Prev Next 



ftpjput 

ftp_fput ~ Uploads from an open file to the FTP server. 

Description 

int f tp_f put(int ftp_stream, string remote_file, int fp, int mode); 

Returns true on success, false on error. 

ftp_fput() uploads the data from the file pointer fp until end of file. The results are stored in 
remote_file on the FTP server. The transfer mode specified must be either FTP_ASCII or 
FTP_BINARY. 

Prev Home Next 

ftp_put U£ ftp_size 



PHP Manual 

Prev Next 



ftp_size 

ftp_size ~ Returns the size of the given file. 

Description 

int ftp_si z e(int ftp_stream, string remote_file); 

Returns the file size on success, or -1 on error. 

ftp_size() returns the size of a file. If an error occurs, of if the file does not exist, - 1 is returned. Not 
all servers support this feature. 

Prev Home Next 

ftp_fput Up ftp_mdtm 



PHP Manual 

Prev Next 



ftp_mdtm 

ftp_mdtm ~ Returns the last modified time of the given file. 

Description 

i n t ft p_mdt m(int ftp_stream, string remote_file) ; 

Returns a UNIX timestamp on success, or -1 on error. 

ftp_mdtm() checks the last-modified time for a file, and returns it as a UNIX timestamp. If an error 
occurs, or the file does not exist, -1 is returned. Note that not all servers support this feature. 

Prev Home Next 

ftp_size Up ftp_rename 



PHP Manual 

Prev Next 



ftp_rename 

ftp_rename ~ Renames a file on the ftp server. 

Description 

int f tp_rename(int ftp_stream, string from, string to); 

Returns true on success, false on error. 

ftp_rename() renames the file specified by from to the new name t o 

Prev Home Next 

ftp_mdtm Up ftp_delete 



PHP Manual 

Prev Next 



ftp_delete 

ftp_delete ~ Deletes a file on the ftp server. 

Description 

i n t ft p_de 1 e t e (int ftp_stream, string path) ; 

Returns true on success, false on error. 

ftp_delete() deletes the file specified hy path from the FTP server. 

Prev Home Next 

ftp_rename Up ftp_quit 



PHP Manual 

Prev Next 



ftp_quit 

ftp_quit ~ Closes an FTP connection 

Description 

i n t ft p_qu i t (int ftp_stream) ; 
ftp_connect() closes ftp_stream. 

Prev Home Next 

ftp_delete U^ Hash functions 



PHP Manual 

Prev Next 



mhash_get_hash_name 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mhash_get_hash_name ~ Get the name of the specified hash 

Description 

string mhash_get_hash_name(int hash); 

mhash_get_hash_name() is used to get the name of the specified hash. 

mhash_get_hash_name() takes the hash id as an argument and returns the name of the hash or 
false, if the hash does not exist. 

Example 1. mhash_get_hash_name example 

<?php 

$hash = MHASH_MD5; 

print mhash_get_hash_name ($hash) ; 
?> 

The above example will print out: 

MD5 



Prev Home Next 

Hash functions Up mhash_get_block_size 



PHP Manual 

Prev Next 



mhash_get_block_size 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mhash_get_block_size ~ Get the block size of the specified hash 

Description 

int mhash_get_block_size(int hash); 

mhash_get_block_size() is used to get the size of a block of the specified hash. 

mhash_get_block_size() takes one argument, the hash and returns the size in bytes or false, if the 
hash does not exist. 

Prev Home Next 

mhash_get_hash_name Up mhash_count 



PHP Manual 

Prev Next 



mhash_count 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mhash_count ~ Get the highest available hash id 

Description 

int mhash_count(void ); 

mhash_count() returns the highest available hash id. Hashes are numbered from to this hash id. 
Example 1. Traversing all hashes 

<?php 

$nr = mhash_count ( ) ; 

for($i = 0; $i <= $nr; $i++) { 

echo sprintf ("The blocksize of %s is %d\n", 
mhash_get_hash_name ($i) , 
mhash_get_block_size ($i) ) ; 

} 
?> 



Prev Home Next 

mhash_get_block_size Up mhash 



PHP Manual 

Prev Next 



ImageChar 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageChar — draw a character horizontally 

Description 

int image char(int im, int font, int x, int y, string c, int col); 

ImageChar draws the first character of c in the image identified by i d with its upper-left at x,y 
(top left is 0,0) with the color col. If font is 1, 2, 3, 4 or 5, a built-in font is used (with higher 
numbers corresponding to larger fonts). 

See also imageloadfontQ . 

Prev Home Next 

ImageArc Up ImageCharUp 



PHP Manual 

Prev Next 



ImageCharllp 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageCharUp ~ draw a character vertically 

Description 

int image charup(int im, int font, int x, int y, string c, int col); 

ImageCharUp draws the character c vertically in the image identified by im at coordinates x, y (top 
left is 0, 0) with the color col. If font is 1, 2, 3, 4 or 5, a built-in font is used. 

See also imageloadfontQ . 

Prev Home Next 

ImageChar U^ ImageColorAllocate 



PHP Manual 

Prev Next 



ImageColorAllocate 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorAllocate ~ allocate a color for an image 

Description 

int imagecolorallocate(int im, intred, int green, intblue); 

ImageColorAllocate returns a color identifier representing the color composed of the given RGB 
components. The im argument is the return from the imagecreateQ function. ImageColorAllocate 
must be called to create each color that is to be used in the image represented by im. 

$white = ImageColorAllocate ( $im, 255,255,255); 
$black = ImageColorAllocate ($im, 0,0,0); 

Prev Home Next 

ImageCharUp Up ImageColorAt 



PHP Manual 

Prev Next 



ImageColorAt 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorAt ~ get the index of the color of a pixel 

Description 

int imagecolorat(int im, int x, int y); 

Returns the index of the color of the pixel at the specified location in the image. 

See also imagecolorsetQ and imagecolorsf orindexQ . 

Prev Home Next 

ImageColorAllocate U^ ImageColorClosest 



PHP Manual 

Prev Next 



ImageColorClosest 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorClosest ~ get the index of the closest color to the specified color 

Description 

int imagecolorclosest(int im, intred, int green, intblue); 

Returns the index of the color in the palette of the image which is "closest" to the specified RGB 
value. 

The "distance" between the desired color and each color in the palette is calculated as if the RGB 
values represented points in three-dimensional space. 

See also imagecolorexactQ . 

Prev Home Next 

ImageColorAt Up ImageColorExact 



PHP Manual 

Prev Next 



ImageColorExact 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorExact ~ get the index of the specified color 

Description 

int imagecolorexact(int im, int red, int green, int blue); 
Returns the index of the specified color in the palette of the image. 
If the color does not exist in the image's palette, - 1 is returned. 
See also imagecolorclosestQ . 

Prev Home Next 

ImageColorClosest Up ImageColorResolve 



PHP Manual 

Prev Next 



ImageColorResolve 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImageColorResolve ~ get the index of the specified color or its closest possible alternative 

Description 

int imagecolorresolve(int im, intred, int green, intblue); 

This function is guaranteed to return a color index for a requested color, either the exact color or the 
closest possible alternative. 

See also imagecolorclosestQ . 

Prev Home Next 

ImageColorExact Ug ImageColorSet 



PHP Manual 

Prev Next 



ImageColorSet 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorSet ~ set the color for the specified palette index 

Description 

bool imagecolorset (int im, int index, int red, int green, int blue) ; 

This sets the specified index in the palette to the specified color. This is useful for creating 
flood-fill-like effects in paletted images without the overhead of performing the actual flood-fill. 

See also imagecoloratQ . 

Prev Home Next 

ImageColorResolve U^ ImageColorsForlndex 



PHP Manual 

Prev Next 



ImageColorsForlndex 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorsForlndex ~ get the colors for an index 

Description 

array imagecolorsf orindex(int im, int index); 

This returns an associative array with red, green, and blue keys that contain the appropriate values 
for the specified color index. 

See also imagecoloratQ and imagecolorexactQ . 

Prev Home Next 

ImageColorSet Ug ImageColorsTotal 



PHP Manual 

Prev Next 



ImageColorsTotal 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorsTotal ~ find out the number of colors in an image's palette 

Description 

int imagecolorstotal(int im); 

This returns the number of colors in the specified image's palette. 

See also imagecoloratQ and imagecolorsforindexQ . 

Prev Home Next 

ImageColorsForlndex Ug ImageColorTransparent 



PHP Manual 

Prev Next 



ImageColorTransparent 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageColorTransparent ~ define a color as transparent 

Description 

int imagecolortransparent(int im, int [col]); 

ImageColorTransparent sets the transparent color in the im image to col. im is the image identifier 
returned by imagecreateQ and col is a color identifier returned by imagecolorallocateQ . 

The identifier of the new (or current, if none is specified) transparent color is returned. 

Prev Home Next 

ImageColorsTotal Ug ImageCopyResized 



PHP Manual 

Prev Next 



ImageCopyResized 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageCopyResized ~ copy and resize part of an image 

Description 



int imagecopyresi zed(int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, 
int dstH, int srcW, int srcH); 

ImageCopyResized copies a rectangular portion of one image to another image. dst_im is the 
destination image, src_im is the source image identifier. If the source and destination coordinates 
and width and heights differ, appropriate stretching or shrinking of the image fragment will be 
performed. The coordinates refer to the upper left corner. This function can be used to copy regions 
within the same image (if dst_im is the same as src_im) but if the regions overlap the results 
will be unpredictable. 

Prev Home Next 

ImageColorTransparent U^ ImageCreate 



PHP Manual 

Prev Next 



ImageCreate 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImageCreate ~ create a new image 

Description 

int image cr eat e(int x_size, int y_size); 

ImageCreate returns an image identifier representing a blank image of size x_size by y_size. 

Prev Home Next 

ImageCopyResized Up ImageCreateFromGif 



PHP Manual 

Prev Next 

ImageCreateFromGif 

■his function is not supported in the^^f 
■HP Lite edition. ^^ 

■ossible workaround not yet publish^fl 

ImageCreateFromGif ~ create a new image from file or URL 

Description 

int imagecreatefromgif (string filename); 

imagecreatefromgifO returns an image identifier representing the image obtained from the given filename. 

imagecreatefromgifO returns an empty string on failure. It also outputs an error message, which unfortunately 
displays as a broken link in a browser. To ease debugging the following example will produce an error GIF: 

Example 1. Example to handle an error during creation (courtesy vic@zymsys,com ) 

function LoadGif ($imgname) 
{ 

$im = @imagecreatef romgif ( $imgname) ; /* Attempt to open */ 
if ($im == "") { /* See if it failed */ 

$im = ImageCreate ( 150, 30) ; /* Create a blank image */ 

$bgc = ImageColorAllocate ($im, 255, 255, 255) ; 

$tc = ImageColorAllocate ($im, 0, 0, 0) ; 

ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc) ; 

ImageString ( $im, 1 , 5 , 5 , "Error loading $imgname" , $tc) ; /* Output an errmsg */ 

} 

return $im; 

} 

Note: Since all GIF support was removed from the GD library in version 1 .6, this function is not 
available if you are using that version of the GD hbrary. 

Prev Home Next 

ImageCreate U^ ImageDashedLine 



PHP Manual 

Prev Next 



ImageDashedLine 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageDashedLine ~ draw a dashed Hne 

Description 



int imagedashedline(int im, int xl, int yl, int x2, int y2, int col); 

ImageLine draws a dashed hne from xl,y 1 to x2,y2 (top left is 0,0) in image im of color col. 

See also imagelineQ . 

Prev Home Next 

ImageCreateFromGif U^ ImageDestroy 



PHP Manual 

Prev Next 



ImageDestroy 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImageDestroy ~ destroy an image 

Description 

int imagedestroy(int im); 

ImageDestroy frees any memory associated with image im. im is the image identifier returned by 
the JmagecreateQ function. 

Prev Home Next 

ImageDashedLine Up ImageFill 



PHP Manual 

Prev Next 



ImageFill 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImageFill ~ flood fill 

Description 

int imagef ill(int im, int x, inty, int col); 

ImageFill performs a flood fill starting at coordinate x, y (top left is 0,0) with color col in the image 
im. 

Prev Home Next 

ImageDestroy Up ImageFilledPolygon 



PHP Manual 

Prev Next 



ImageFilledPolygon 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageFilledPolygon — draw a filled polygon 

Description 

int imagef illedpolygon(int im, array points, int num_points, int col); 

ImageFilledPolygon creates a filled polygon in image im. points is a PHP array containing the 
polygon's vertices, ie. points[0] = xO, points[l] = yO, points[2] = xl, points[3] = yl, etc. num_points 
is the total number of vertices. 

Prev Home Next 

ImageFill U^ ImageFilledRectangle 



PHP Manual 

Prev Next 



ImageFilledRectangle 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageFilledRectangle ~ draw a filled rectangle 

Description 

int imagef illedrectangle(int im, int xl, int yl, int x2, int y2, int col); 

ImageFilledRectangle creates a filled rectangle of color col in image im starting at upper left 
coordinates xl, y 1 and ending at bottom right coordinates x2, y2. 0, is the top left corner of the 
image. 

Prev Home Next 

ImageFilledPolygon U^ ImageFillToB order 



PHP Manual 

Prev Next 



ImageFillToBorder 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageFillToBorder ~ flood fill to specific color 

Description 

int imagef illtoborder(int im, int x, inty, int border, int col); 

ImageFillToBorder performs a flood fill whose border color is defined by border. The starting point 
for the fill is x,y (top left is 0,0) and the region is filled with color col. 

Prev Home Next 

ImageFilledRectangle Up ImageFontHeight 



PHP Manual 

Prev Next 



ImageFontHeight 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageFontHeight ~ get font height 

Description 

int imagef ontheight(int font); 

Returns the pixel height of a character in the specified font. 

See also imagefontwidthQ and imageloadf ontQ . 



Prev Home Next 

ImageFillToB order Ug ImageFontWidth 



PHP Manual 

Prev Next 



ImageFontWidth 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageFontWidth ~ get font width 

Description 



int imagef ontwidth(int font); 
Returns the pixel width of a character in font. 
See also imagefontheightQ and imageloadfontQ . 



Prev Home Next 

ImageFontHeight U^ ImageGif 



PHP Manual 

Prev Next 



ImageGif 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageGif ~ output image to browser or file 

Description 

int imagegif (int im, string filename); 

imagegifO creates the GIF file in filename from the image im. The im argument is the return from 
the JmagecreateQ function. 

The image format will be GIF87a unless the image has been made transparent with 
JmagecolortransparentQ , in which case the image format will be GIF89a. 

The filename argument is optional, and if left off, the raw image stream will be output directly. By 
sending an image/gif content-type using headerQ , you can create a PHP script that outputs GIF 
images directly. 

Note: Since all GIF support was removed from the GD library in version 1.6, this 
function is not available if you are using that version of the GD library. 

Prev Home Next 

ImageFontWidth Up Imagelnterlace 



PHP Manual 

Prev Next 



Imagelnterlace 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Imagelnterlace ~ enable or disable interlace 

Description 

int imageinterlace(int im, int [interlace]); 

ImagelnterlaceQ turns the interlace bit on or off. If interlace is 1 the im image will be interlaced, 
and if interlace is the interlace bit is turned off. 

This functions returns whether the interlace bit is set for the image. 

Prev Home Next 

ImageGif Ug ImageLine 



PHP Manual 

Prev Next 



ImageLine 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImageLine ~ draw a Hne 

Description 

int imageline(int im, int xl, int yl, int x2, int y2, int col); 

ImageLine draws a Hne from xl,yl to x2,y2 (top left is 0,0) in image im of color col. 

See also imagecreateQ and imagecolorallocateQ . 

Prev Home Next 

Imagelnterlace Ug ImageLoadFont 



PHP Manual 



Prev 



Next 



ImageLoadFont 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



|dJ 



ImageLoadFont ~ load a new font 

Description 

int imageloadf ont(string file); 

ImageLoadFont loads a user-defined bitmap font and returns an identifier for the font (that is 
always greater than 5, so it will not conflict with the built-in fonts). 

The font file format is currently binary and architecture dependent. This means you should generate 
the font files on the same type of CPU as the machine you are running PHP on. 

Table 1. Font file format 



byte position 


C data type 


description 


byte 0-3 


int 


number of characters in the font 


byte 4-7 


int 


value of first character in the font (often 32 for space) 


byte 8-11 


int 


pixel width of each character 


byte 12-15 


int 


pixel height of each character 


byte 16- 


char 


array with character data, one byte per pixel in each character, for a 
total of (nchars* width *height) bytes. 


See also ImageFontWidthQ and ImageFontHeightQ. 



Prev 
ImageLine 



Home 
Up 



Next 
ImagePolygon 



PHP Manual 

Prev Next 



ImagePolygon 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImagePolygon — draw a polygon 

Description 

int imagepolygon(int im, array points, int num_points, int col); 

ImagePolygon creates a polygon in image id. points is a PHP array containing the polygon's 
vertices, ie. points[0] = xO, points[l] = yO, points[2] = xl, points[3] = yl, etc. num_points is the 
total number of vertices. 

See also imagecreateQ . 

Prev Home Next 

ImageLoadFont Up ImagePSBBox 



PHP Manual 

Prev Next 



ImagePSBBox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImagePSBBox ~ give the bounding box of a text rectangle using PostScript Typel fonts 

Description 

array imagepsbbox(string text, int font, int size, int space, int width, float angle); 

size is expressed in pixels. 

space allows you to change the default value of a space in a font. This amount is added to the 
normal value and can also be negative. 

tightness allows you to control the amount of white space between characters. This amount is 
added to the normal character width and can also be negative. 

angle is in degrees. 

Parameters space and tightness are expressed in character space units, where 1 unit is 
1/lOOOth of an em- square. 

Parameters space, tightness and angle are optional. 

The bounding box is calculated using information available from character metrics, and 
unfortunately tends to differ slightly from the results achieved by actually rasterizing the text. If the 
angle is degrees, you can expect the text to need 1 pixel more to every direction. 

This function returns an array containing the following elements: 







lower left x-coordinate 



lower left y-coordinate 



upper right x-coordinate 



upper right y-coordinate 



See also imagepstextQ . 



Prev Home Next 

ImagePolygon Up ImagePSEncodeFont 



PHP Manual 

Prev Next 



ImagePSEncodeFont 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImagePSEncodeFont ~ change the character encoding vector of a font 

Description 

int imagepsencodef ont(string encodingfile); 

Loads a character encoding vector from from a file and changes the fonts encoding vector to it. As 
a PostScript fonts default vector lacks most of the character positions above 127, you'll definitely 
want to change this if you use an other language than english. The exact format of this file is 
described in Tllibs documentation. Tllib comes with two ready-to-use files, IsoLatinl.enc and 
IsoLatin2.enc. 

If you find yourself using this function all the time, a much better way to define the encoding is to 
set ps.default_encoding in the configuration file to point to the right encoding file and all fonts you 
load will automatically have the right encoding. 

Prev Home Next 

ImagePSBBox Up ImagePSFreeFont 



PHP Manual 

Prev Next 



ImagePSFreeFont 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImagePSFreeFont ~ free memory used by a PostScript Type 1 font 

Description 

void imagepsf reef ont(int fontindex); 
See also imagepsloadfontQ . 

Prev Home Next 

ImagePSEncodeFont Up ImagePSLoadFont 



PHP Manual 

Prev Next 



ImagePSLoadFont 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImagePSLoadFont ~ load a PostScript Type 1 font from file 

Description 

int imagepsloadf ont(string filename); 

In the case everything went right, a valid font index will be returned and can be used for further 
purposes. Otherwise the function returns false and prints a message describing what went wrong. 

See also imagepsfreefontQ . 

Prev Home Next 

ImagePSFreeFont Ug ImagePSText 



PHP Manual 

Prev Next 



ImagePSText 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ImagePSText ~ to draw a text string over an image using PostScript Typel fonts 

Description 

array imagepstext(int image, string text, int font, int size, int foreground, int background, int 
X, int y, int [space], int [tightness], float [angle], int [antialias_steps]); 

size is expressed in pixels. 

foreground is the color in which the text will be painted, background is the color to which 
the text will try to fade in with antialiasing. No pixels with the color background are actually 
painted, so the background image does not need to be of solid color. 

The coordinates given by x, y will define the origin (or reference point) of the first character 
(roughly the lower-left corner of the character). This is different from the ImageStringQ , where x, 
y define the upper-right corner of the first character. Refer to PostScipt documentation about fonts 
and their measuring system if you have trouble understanding how this works. 

space allows you to change the default value of a space in a font. This amount is added to the 
normal value and can also be negative. 

tightness allows you to control the amount of white space between characters. This amount is 
added to the normal character width and can also be negative. 

angle is in degrees. 

antialias_steps allows you to control the number of colours used for antialiasing text. 
Allowed values are 4 and 16. The higher value is recommended for text sizes lower than 20, where 
the effect in text quality is quite visible. With bigger sizes, use 4. It's less computationally intensive. 

Parameters space and tightness are expressed in character space units, where 1 unit is 
1/1 000th of an em- square. 

Parameters space, tightness, angle and antialias are optional. 

This function returns an array containing the following elements: 







lower left x-coordinate 



lower left y-coordinate 



upper right x-coordinate 



3 upper right y-coordinate 



See also imagepsbboxQ . 



Prev 
ImagePSLoadFont 



Home 
Up 



Next 
ImageRectangle 



PHP Manual 

Prev Next 



ImageRectangle 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageRectangle ~ draw a rectangle 

Description 

int imagerectangle(int im, int xl, int yl, int x2, int y2, int col); 

ImageRectangle creates a rectangle of color col in image im starting at upper left coordinate xl,y 1 
and ending at bottom right coordinate x2,y2. 0,0 is the top left corner of the image. 

Prev Home Next 

ImagePSText Up ImageSetPixel 



PHP Manual 

Prev Next 



ImageSetPixel 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageSetPixel ~ set a single pixel 

Description 

int imagesetpixel(int im, int x, int y, int col); 

ImageSetPixel draws a pixel at x,y (top left is 0,0) in image im of color col. 

See also imagecreateQ and imagecolorallocateQ . 

Prev Home Next 

ImageRectangle Ug ImageString 



PHP Manual 

Prev Next 



ImageString 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageString — draw a string horizontally 

Description 

int imagestring(int im, int font, int x, int y, string s, int col); 

ImageString draws the string s in the image identified by im at coordinates x,y (top left is 0,0) in 
color col. If font is 1, 2, 3, 4 or 5, a built-in font is used. 

See also imageloadfontQ . 

Prev Home Next 

ImageSetPixel Ug ImageStringUp 



PHP Manual 

Prev Next 



ImageStringUp 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageStringUp ~ draw a string vertically 

Description 

int imagestringup(int im, int font, int x, int y, string s, int col); 

ImageStringUp draws the string s vertically in the image identified by im at coordinates x,y (top 
left is 0,0) in color col. If font is 1, 2, 3, 4 or 5, a built-in font is used. 

See also imageloadfontQ . 

Prev Home Next 

ImageString U^ ImageSX 



PHP Manual 

Prev Next 



ImageSX 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageSX ~ get image width 

Description 

int image sx(int im); 

ImageSX returns the width of the image identified by im. 

See also imagecreateQ and imagesyQ. 



Prev Home Next 

ImageStringUp U^ ImageSY 



PHP Manual 

Prev Next 



ImageSY 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageSY ~ get image height 

Description 

int image sy(int im); 

ImageSY returns the height of the image identified by im. 

See also imagecreateQ and imagesxQ. 



Prev Home Next 

ImageSX Ug ImageTTFBBox 



PHP Manual 

Prev Next 



ImageTTFBBox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ImageTTFBBox ~ give the bounding box of a text using TypeType fonts 

Description 

array ImageTTFBBox(int size, int angle, string fontfile, string text); 

This function calculates and returns the bounding box in pixels a TrueType text. 

text 

The string to be measured. 

size 

The font size. 

fontfile 

The name of the TrueType font file. (Can also be an URL.) 

angle 

Angle in degrees in which text will be measured. 
ImageTTFBBoxQ returns an array with 8 elements representing four points making the bounding 
box of the text: 







6 



7 



lower left comer, X position 



lower left corner, Y position 



lower right corner, X position 



lower right corner, Y position 



upper right corner, X position 



upper right corner, Y position 



upper left corner, X position 



upper left corner, Y position 



The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand 
corner seeing the text horizontally. 



This function requires botli tlie GD library and the Freetype Hbrary. 
See also ImageTTFTextQ . 

Prev Home Next 

ImageSY Ug ImageTTFText 



PHP Manual 

Prev Next 



ImageTTFText 

Ehis function is not supported in the^^f 
HP Lite edition. ~^H 

ossible workaround not yet publis^^H 

ImageTTFText — write text to the image using TrueType fonts 

Description 

array ImageTTFText(int im, int size, int angle, int x, int y, int col, string fontfile, string text); 

ImageTTFText draws the string text in the image identified by im, starting at coordinates x, y (top left is 0,0), at 
an angle of angle in color col, using the TrueType font file identified by fontfile. 

The coordinates given by x,y will define the basepoint of the first character (roughly the lower- left corner of the 
character). This is different from the ImageStringQ , where x,y define the upper-right corner of the first character. 

angle is in degrees, with degrees being left-to-right reading text (3 o'clock direction), and higher values 
representing a counter-clockwise rotation, (i.e., a value of 90 would result in bottom-to-top reading text). 

fon t file is the path to the TrueType font you wish to use. 

text is the text string which may include UTF-8 character sequences (of the form: { ) to access characters in 
a font beyond the first 255. 

col is the color index. Using the negative of a color index has the effect of turning off antialiasing. 

ImageTTFTextQ returns an array with 8 elements representing four points making the bounding box of the text. 
The order of the points is upper left, upper right, lower right, lower left. The points are relative to the text regardless 
of the angle, so "upper left" means in the top left-hand corner when you see the text horizontallty. 

This example script will produce a black GIF 400x30 pixels, with the words "Testing..." in white in the font Arial. 

Example 1. ImageTTFText 

<?php 

Header ( "Content-type : image/gif " ) ; 

$im = imagecreate (400, 30) ; 

$black = ImageColorAllocate ( $im, 0,0,0); 

$white = ImageColorAllocate ( $im, 255,255,255); 

ImageTTFText ($im, 20, 0, 10, 20, $white, "/path/arial . ttf " , "Testing... Omega: 

&#937; ") ; 

ImageGif ( $im) ; 

ImageDestroy ($im) ; 

?> 

This function requires both the GD library and the FreeType library. 

See also ImageTTFBBoxQ . 

Prev Home Next 



ImageTTFBBox U^ IMAP functions 



PHP Manual 

Prev Next 



imap_append 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_append ~ Append a string message to a specified mailbox 

Description 

int imap_append(int imap_stream, string mbox, string message, stringflags); 

Returns true on sucess, false on error. 

imap_append() appends a string message to the specified mailbox mbox. If the optional flags is 
specified, writes the flags to that mailbox also. 

When talking to the Cyrus IMAP server, you must use "\r\n" as your end-of-line terminator instead 
of "\n" or the operation will fail. 

Prev Home Next 

IMAP functions IJ£ imap_base64 



PHP Manual 

Prev Next 



imap_open 



iThis function is not supported in 
PHP Lite edition, 
tossibl^wo^aroun^xo^e^ubl 



^ 



imap_open ~ Open an IMAP stream to a mailbox 

Description 

int imap_open(string mailbox, string username, string password, int flags); 

Returns an IMAP stream on success and false on error. This function can also be used to open 
streams to POPS and NNTP servers. To connect to an IMAP server running on port 143 on the local 
machine, do the following: 

$mbox = iinap_open ( " { localhost : 143 } INBOX" , "user_id" , "password" ) ; 

To connect to a POPS server on port 1 10 on the local server, use: 

$mbox = imap_open ( " { localhost /pop3 : 110 } INBOX" , "user_id" , "password" ) ; 

To connect to an NNTP server on port 1 19 on the local server, use: 

$nntp = imap_open ( " { localhost /nntp : 119 } comp .test" , " " , " " ) ; 

To connect to a remote server replace "localhost" with the name or the IP address of the server you 
want to connect to. 

The options are a bit mask with one or more of the following: 

q OP_READONLY - Open mailbox read-only 

q OP_ANONYMOUS - Dont use or update a .newsrc for news 

q OP_HALFOPEN - For IMAP and NNTP names, open a connection but dont open a mailbox 

q CL_EXPUNGE - Expunge mailbox automatically upon mailbox close 

Prev Home Next 

imap_num_recent Up imap_ping 



PHP Manual 

Prev Next 



imap_base64 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_base64 ~ Decode BASE64 encoded text 

Description 

string imap_base64(string text); 

imap_base64() function decodes BASE-64 encoded text. The decoded message is returned as a 
string. 

Prev Home Next 

imap_append Up imap_body 



PHP Manual 

Prev Next 



imap_body 



This function is not supported in 

PHP Lite edition. 

Possible workaround not yet publish 



lish^^l 



DIV CLASS="REFNAMEDIV" >imap_body -- Read the message body 

Description 

string imap_body(int imap_stream, int msg_number, int flags); 

imap_body() returns the body of the message, numbered msg_number in the current mailbox. 
The optional flags are a bit mask with one or more of the following: 

q FT_UID - The msgno is a UID 

q FT_PEEK - Do not set the \Seen flag if not already set 

q FT_INTERNAL - The return string is in internal format, will not canonicalize to CRLF. 

Prev Home Next 

imap_base64 Up imap_check 



PHP Manual 

Prev Next 



imap_check 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_check ~ Check current mailbox 

Description 

array imap_check(int imap_stream); 

Returns information about the current mailbox. Returns FALSE on failure. 

The imap_check() function checks the current mailbox status on the server and returns the 
information in an object with following properties. 

Date : date of the message 
Driver : driver 

Mailbox : name of the mailbox 
Nmsgs : number of messages 
Recent : number of recent messages 



Prev Home Next 

imap_body Up imap_close 



PHP Manual 

Prev Next 



imap_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_close ~ Close an IMAP stream 

Description 

int imap_close(int imap_stream, int flags); 

Close the imap stream. Takes an optional flag CL_EXPUNGE, which will silently expunge the 
mailbox before closing. 

Prev Home Next 

imap_check Up imap_createmailbox 



PHP Manual 

Prev Next 



imap_createmailbox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_createmailbox — Create a new mailbox 

Description 

int imap_createmailbox(int imap_stream, string mbox); 
imap_createmailbox() creates a new mailbox specified by mbox. 
Returns true on success and false on error. 

Prev Home Next 

imap_close U^ imap_delete 



PHP Manual 

Prev Next 



imap_delete 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_delete ~ Mark a messge for deletion from current mailbox 

Description 

int imap_delete(int imap_stream, int msg_number); 

Returns true. 

imap_delete() function marks message pointed by msg_number for deletion. Actual deletion of 
the messages is done by imap_expunge() . 

Prev Home Next 

imap_createmailbox Ug imap_deletemailbox 



PHP Manual 

Prev Next 



imap_deletemailbox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_deletemailbox — Delete a mailbox 

Description 

int imap_deletemailbox(int imap_stream, string mbox); 
imap_deletemailbox() deletes the specified mailbox. 
Returns true on success and false on error. 

Prev Home Next 

imap_delete U^ imap_expunge 



PHP Manual 

Prev Next 



imap_expunge 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_expunge ~ Delete all messages marked for deletion 

Description 

int imap_expunge(int imap_stream); 

imap_expunge() deletes all the messages marked for deletion by imap_delete() . 

Returns true. 

Prev Home Next 

imap_deletemailbox Ug imap_fetchbody 



PHP Manual 

Prev Next 



imap_fetchbody 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_fetchbody ~ Fetch a particular section of the body of the message 

Description 

string imap_f etchbody(int imap_stream, int msg_number, string part_number, flags flags); 

This function causes a fetch of a particular section of the body of the specified messages as a text 
string and returns that text string. The section specification is a string of integers delimited by 
period which index into a body part list as per the IMAP4 specification. Body parts are not decoded 
by this function. 

The options for imap_fetchbody ()e a bitmask with one or more of the following 

q FT_UID - The msgono is a UID 

q FT_PEEK - Do not set the \Seen flag if not already set 

q FT_UID - The return string is in "internal" format, without any attempt to canonicalize 
CRLF 

Prev Home Next 

imap_expunge Up imap_fetchstructure 



PHP Manual 



Prev 



Next 



imap_fetchstructure 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



|dJ 



imap_fetchstructure ~ Read the structure of a particular message 



Description 



object imap_f etchstructure(int imap_stream, int msg_number, int [flags] ); 

This function fetches all the structured information for a given message. The optional flags 
parameter only has a single option, FT_UID, which tells the function to treat the msg_number 
argument as a UID. The returned object includes the envelope, internal date, size, flags and body 
structure along with a similar object for each mime attachement. The structure of the returned 
objects is as follows: 

Table 1. Returned Objects for imap_fetchstructure() 



type 


Primary body type 


encoding 


Body transfer encoding 


ifsubtype 


True if there is a subtype string 


subtype 


MIME subtype 


ifdescription 


True if there is a description string 


description 


Content description string 


ifid 


True if there is an identification string 


id 


Identification string 


lines 


Number of lines 


bytes 


Number of bytes 


ifdisposition 


True if there is a disposition string 


disposition 


Disposition string 


ifdparameters 


True if the dparameters array exists 


dparameters [a] 


Disposition parameter array 


ifparameters 


True if the parameters array exists 


parameters [b] 


MIME parameters array 


parts [c] 


Array of objects describing each message part 



Notes: 

a. dparameters is an array of objects where each object has an "attribute" and a "value" property. 

b. parameter is an array of objects where each object has an "attributte" and a "value" property. 

c. parts is an array of objects identical in structure to the top-level object, with the limitation that it 
cannot contain further 'parts' objects. 



Prev Home Next 

imap_fetchbody U^ imap_header 



PHP Manual 

Prev Next 



imap_header 

I his function is not supported in the I 
HP Lite edition. ■ 

ossible workaround not yet publisiMiJ 

imap_header ~ Read the header of the message 

Description 



object imap_header(int imap_stream, int msg_number, int [fromlength] , int [subjectlength] , string 
[defaulthost] ); 

This function returns an object of various header elements 

remail,date,Date,subject,Subject,in_reply_to,message_id,newsgroups, 
followup_to ,ref erences 

message flags: 

Recent - 'R' if recent and seen, 'N' if recent and not seen, ' ' if not recent 

Unseen - 'U' if not seen AND not recent, ' ' if seen OR not seen and recent 

Answered - 'A' if answered, ' ' if unanswered 

Deleted - 'D' if deleted, ' ' if not deleted 

Draft - 'X' if draft, ' ' if not draft 

Flagged - 'F' if flagged, ' ' if not flagged 
NOTE that the Recent/Unseen behavior is a little odd. If you want to know if a message is Unseen, you must check for 
Unseen == 'U' II Recent == 'N' 

toaddress (full to: line, up to 1024 characters) 

to[] (returns an array of objects from the To line, containing:) 
personal 
adl 

mailbox 
host 

fromaddress (full from: line, up to 1024 characters) 

from[] (returns an array of objects from the From line, containing:) 
personal 
adl 

mailbox 
host 

ccaddress (full cc: line, up to 1024 characters) 

cc[] (returns an array of objects from the Cc line, containing:) 

personal 

adl 

mailbox 



host 

bccaddress (full bcc line, up to 1024 characters) 

bcc[] (returns an array of objects from the Bcc line, containing:) 

personal 

adl 

mailbox 

host 

reply_toaddress (full reply _to: line, up to 1024 characters) 

reply _to[] (returns an array of objects from the Reply _to line, containing:) 

personal 

adl 

mailbox 

host 

senderaddress (full sender: line, up to 1024 characters) 

sender[] (returns an array of objects from the sender line, containing:) 

personal 

adl 

mailbox 

host 

return_path (full return-path: line, up to 1024 characters) 

return_path[] (returns an array of objects from the return_path line, containing:) 

personal 

adl 

mailbox 

host 

udate ( mail message date in unix time) 

fetchfrom (from line formatted to fit fromlength characters) 
fetchsubject (subject line formatted to fit subjectlength characters) 



Prev Home Next 

imap_fetchstructure Up imap_headers 



PHP Manual 

Prev Next 



imap_headers 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_headers ~ Returns headers for all messages in a mailbox 

Description 

array imap_headers(int imap_stream); 

Returns an array of string formatted with header info. One element per mail message. 

Prev Home Next 

imap_header Up imap_listmailbox 



PHP Manual 

Prev Next 



imapjistmailbox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imapjistmailbox ~ Read the Hst of mailboxes 

Description 

array imap_listmailbox(int imap_stream, string ref, string pat); 
Returns an array containing the names of the mailboxes. 

Prev Home Next 

imap_headers Up imap_getmailboxes 



PHP Manual 

Prev Next 



imap_getmailboxes 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_getmailboxes ~ Read the Hst of mailboxes, returning detailed information on each one 

Description 

array imap_getmailboxes(int imap_stream, string ref, string pat); 

Returns an array of objects containing mailbox information. Each object has the attributes name, 
specifying the full name of the mailbox; delimiter, which is the hierarchy delimiter for the part 
of the hierarchy this mailbox is in; and attributes. Attributesis a bitmask that can be 
tested against: 

q LATT_NOINFERIORS - This mailbox has no "children" (there are no mailboxes below this 
one) 

q LATT_NOSELECT - This is only a container, not a mailbox - you cannot open it. 

q LATT_MARKED - This mailbox is marked. Only used by UW-IMAPD. 

q LATT_UNMARKED - This mailbox is not marked. Only used by UW-IMAPD. 

ref should normally be just the IMAP server, in the form: {imap_server:imap_port}, and 
pattern specifies where in the mailbox hierarchy to start searching. If you want all mailboxes, 
pass pattern as an empty string. 

There are two special characters you can pass as part of the pattern: '*' and '%'. '*' means to 
return all mailboxes. If you pass pattern as '*', you will get a list of the entire mailbox hierarchy. 
'%' means to return the current level only. '%' as the pattern parameter will return only the top 
level mailboxes; '~/mail/%' on UW_IMAPD will return every mailbox in the -/mail directory, but 
none in subfolders of that directory. 

Prev Home Next 

imap_listmailbox lj£ imap_listsubscribed 



PHP Manual 

Prev Next 



imapjistsubscribed 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imapjistsubscribed ~ List all the subscribed mailboxes 

Description 

array imap_listsubscribed(int imap_stream, string ref, string pattern); 

Returns an array of all the mailboxes that you have subscribed. The ref and pattern arguments 
specify the base location to search from and the pattern the mailbox name must match. 

Prev Home Next 

imap_getmailboxes Up imap_getsubscribed 



PHP Manual 

Prev Next 



imap_getsubscribed 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_getsubscribed ~ List all the subscribed mailboxes 

Description 

array imap_getsubscribed(int imap_stream, string ref, string pattern); 

This function is identical to imap_getmailboxes() , except that it only returns mailboxes that the 
user is subscribed to. 

Prev Home Next 

imap_listsubscribed Up imap_mail_copy 



PHP Manual 

Prev Next 



imap_mail_copy 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_mail_copy ~ Copy specified messages to a mailbox 

Description 

int imap_mail_copy(int imap_stream, string msghst, string mbox, int flags); 

Returns true on success and false on error. 

Copies mail messages specified hy msglist to specified mailbox, msgllst is a range not just 
message numbers. 

flags is a bitmask of one or more of 

q CP_UID - the sequence numbers contain UIDS 

q CP_MOVE - Delete the messages from the current mailbox after copying 

Prev Home Next 

imap_getsubscribed Up imap_mail_move 



PHP Manual 

Prev Next 



imap_mail_move 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_mail_move ~ Move specified messages to a mailbox 

Description 

int imap_mail_move(int imap_stream, string msghst, string mbox); 

Moves mail messages specified hy msglist to specified mailbox, msglist is a. range not just 
message numbers. 

Returns true on success and false on error. 

Prev Home Next 

imap_mail_copy U^ imap_num_msg 



PHP Manual 

Prev Next 



imap_num_msg 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_num_msg ~ Gives the number of messages in the current mailbox 

Description 

int imap_num_msg(int stream_id); 

Return the number of messages in the current mailbox. 

Prev Home Next 

imap_mail_move Up imap_num_recent 



PHP Manual 

Prev Next 



imap_num_recent 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_num_recent ~ Gives the number of recent messages in current mailbox 

Description 

int imap_num_recent(int imap_stream); 

Returns the number of recent messages in the current mailbox. 

Prev Home Next 

imap_num_msg Up imap_open 



PHP Manual 

Prev Next 



imap_ping 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_ping ~ Check if the IMAP stream is still active 

Description 

int imap_ping(int imap_stream); 

Returns true if the stream is still alive, false otherwise. 

imap_ping() function pings the stream to see it is still active. It may discover new mail; this is the 
preferred method for a periodic "new mail check" as well as a "keep alive" for servers which have 
inactivity timeout. 

Prev Home Next 

imap_open Up imap_renamemailbox 



PHP Manual 

Prev Next 



imap_renamemailbox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_renamemailbox ~ Rename an old mailbox to new mailbox 

Description 

int imap_renamemailbox(int imap_stream, string old_mbox, string new_mbox); 
This function renames on old mailbox to new mailbox. 
Returns true on success and false on error. 

Prev Home Next 

imap_ping Ug imap_reopen 



PHP Manual 

Prev Next 



imap_reopen 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_reopen ~ Reopen IMAP stream to new mailbox 

Description 

int imap_re op en (string imap_stream, string mailbox, string [flags]); 

Returns true on success and false on error. 

This function reopens the specified stream to new mailbox. 

The options are a bit mask with one or more of the following: 

q OP_READONLY - Open mailbox read-only 

q OP_ANONYMOUS - Dont use or update a .newsrc for news 

q OP_HALFOPEN - For IMAP and NNTP names, open a connection but dont open a mailbox 

q CL_EXPUNGE - Expunge mailbox automatically upon mailbox close 

Prev Home Next 

imap_renamemailbox Up imap_sub scribe 



PHP Manual 

Prev Next 



imap_subscribe 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_subscribe ~ Subscribe to a mailbox 

Description 

int imap_subscribe(int imap_stream, string mbox); 

Subscribe to a new mailbox. 

Returns true on success and false on error. 



Prev Home Next 

imap_reopen Ug imap_undelete 



PHP Manual 

Prev Next 



imap_undelete 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_undelete ~ Unmark the message which is marked deleted 

Description 

int imap_undelete(int imap_stream, int msg_number); 

This function removes the deletion flag for a specified message, which is set by imap_delete() . 

Returns true on success and false on error. 

Prev Home Next 

imap_subscribe U^ imap_unsubscribe 



PHP Manual 

Prev Next 



imap_unsubscribe 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_unsubscribe ~ Unsubscribe from a mailbox 

Description 

int imap_unsubscribe(int imap_stream, string mbox); 
Unsubscribe from a specified mailbox. 
Returns true on success and false on error. 

Prev Home Next 

imap_undelete U^ imap_qprint 



PHP Manual 

Prev Next 



imap_qprint 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_qprint ~ Convert a quoted-printable string to an 8 bit string 

Description 

string im a p_qprint (string string); 
Convert a quoted-printable string to an 8 bit string 
Returns an 8 bit (binary) string 



Prev Home Next 

imap_unsub scribe U^ imap_8bit 



PHP Manual 

Prev Next 



imap_8bit 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_8bit ~ Convert an 8bit string to a quoted-printable string. 

Description 

string imap_8bit (string string); 

Convert an 8bit string to a quoted-printable string. 

Returns a quoted-printable string 



Prev Home Next 

imap_qprint U^ imap_binary 



PHP Manual 

Prev Next 



imap_binary 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_binary ~ Convert an 8bit string to a base64 string. 

Description 

string imap_binary(string string); 
Convert an 8bit string to a base64 string. 
Returns a base64 string 



Prev Home Next 

imap_8bit U^ imap_scanmailbox 



PHP Manual 

Prev Next 



imap_scanmailbox 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_scanmailbox ~ Read the Hst of mailboxes, takes a string to search for in the text of the 
mailbox 



Description 



array imap_scanmailbox(int imap_stream, string string); 

Returns an array containing the names of the mailboxes that have string in the text of the 
mailbox. 

Prev Home Next 

imap_binary Up imap_mailboxmsginfo 



PHP Manual 

Prev Next 



imap_mailboxmsginfo 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_mailboxmsginfo ~ Get information about the current mailbox 

Description 

array imap_mailboxmsginf o(int imap_stream); 

Returns information about the current mailbox. Returns FALSE on failure. 

The imap_mailboxmsginfo() function checks the current mailbox status on the server and returns 
the information in an object with following properties. 

Date : date of the message 
Driver : driver 

Mailbox : name of the mailbox 
Nmsgs : number of messages 
Recent : number of recent messages 
Unread : number of unread messages 
Size : mailbox size 



Prev Home Next 

imap_scanmailbox Up imap_rfc822_write_address 



PHP Manual 

Prev Next 



imap_rfc822_write_address 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_rfc822_write_address ~ Returns a properly formatted email address given the mailbox, host, 
and personal info. 



Description 



string imap_rf c822_write_address(string mailbox, string host, string personal); 
Returns a properly formatted email address given the mailbox, host, and personal info. 

Prev Home Next 

imap_mailboxmsginfo Up imap_rfc822_parse_adrlist 



PHP Manual 

Prev Next 



imap_rfc822_parse_adrlist 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_rfc822_parse_adrHst ~ Parses an address string 

Description 

string imap_rf c822_parse_adrlist(string address, string default_host); 

This function parses the address tring and for each address, returns an array of objects. The 4 
objects are: 

mailbox - the mailbox name (usemame) 
host - the host name 
personal - the personal name 
adl - at domain source route 



Prev Home Next 

imap_rfc822_write_address Up imap_setflag_full 



PHP Manual 

Prev Next 



imap_setflag_full 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_setflag_full ~ Sets flags on messages 

Description 



string imap_setf lag_f ull(int stream, string sequence, string flag, string options); 

This function causes a store to add the specified flag to the flags set for the messages in the 
specified sequence. 

The options are a bit mask with one or more of the following: 

ST_UID The sequence argument contains UIDs instead of 

sequence numbers 



Prev Home Next 

imap_rfc822_parse_adrlist U^ imap_clearflag_full 



PHP Manual 

Prev Next 



imap_clearflag_full 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_clearflag_full ~ Clears flags on messages 

Description 



string imap_clearf lag_f ull(int stream, string sequence, string flag, string options); 

This function causes a store to delete the specified flag to the flags set for the messages in the 
specified sequence. 

The options are a bit mask with one or more of the following: 

ST_UID The sequence argument contains UIDs instead of 

sequence numbers 



Prev Home Next 

imap_setflag_full U^ imap_sort 



PHP Manual 

Prev Next 



imap_sort 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_sort ~ 

Description 

string imap_sort(int stream, int criteria, int reverse, int options); 

Returns an array of message numbers sorted by the given parameters 

Rev is 1 for reverse- sorting. 

Criteria can be one (and only one) of the following: 

SORTDATE message Date 
SORTARRIVAL arrival date 
SORTFROM mailbox in first From address 
SORTSUBJECT message Subject 
SORTTO mailbox in first To address 

SORTCC mailbox in first cc address 

SORTSIZE size of message in octets 

The flags are a bitmask of one or more of the following: 

SE_UID Return UIDs instead of sequence numbers 

SE_NOPREFETCH Don't prefetch searched messages. 

Prev Home Next 

imap_clearflag_full Up imap_fetchheader 



PHP Manual 

Prev Next 



imap_f etch header 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

imap_fetchheader ~ Returns header for a message 

Description 

stringimap_f etchheader(int imap_stream, int msgno, int flags); 

This function causes a fetch of the complete, unfiltered RFC 822 format header of the specified 
message as a text string and returns that text string. 

The options are: 

FT_UID The msgno argument is a UID 

FTJNTERNAL The return string is in "internal" format, 

without any attempt to canonicalize to CRLF 

newlines 
FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the 

same time. This avoids an extra RTT on an 

IMAP connection if a full message text is 

desired (e.g. in a "save to local file" 

operation) 



Prev Home Next 

imap_sort Ug imap_uid 



PHP Manual 

Prev Next 



imap_uid 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_uid ~ This function returns the UID for the given message sequence number. 

Description 

int imap_uid(int imap_stream, int msgno); 

This function returns the UID for the given message sequence number. It is the inverse of 
imap_msgno() . 

Prev Home Next 

imap_fetchheader Up imap_msgno 



PHP Manual 

Prev Next 



imap_msgno 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_msgno ~ This function returns the message sequence number for the given UID. 

Description 

int imap_msgno(int imap_stream, int uid); 

This function returns the message sequence number for the given UID. It is the inverse of 
imap_uid() . 

Prev Home Next 

imap_uid Up imap_search 



PHP Manual 

Prev Next 



imap_search 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_search ~ This function returns an array of messages matching the given search criteria. 

Description 

array imap_search(int imap_stream, string criteria, int flags); 

This function performs a search on the mailbox currently opened in the given imap stream. 
criteria is a string, delimited by spaces, in which the following keywords are allowed. Any 
multi-word arguments (eg FROM "joe smith") must be quoted. 

q ALL - return all messages matching the rest of the criteria 

q ANSWERED - match messages with the WANSWERED flag set 

q BCC "string" - match messages with "string" in the Bcc: field 

q BEFORE "date" - match messages with Date: before "date" 

q BODY "string" - match messages with "string" in the body of the message 

q CC "string" - match messages with "string" in the Cc: field 

q DELETED - match deleted messages 

q FLAGGED - match messages with the WFLAGGED (sometimes referred to as Important or 
Urgent) flag set 

q FROM "string" - match messages with "string" in the From: field 

q KEYWORD "string" - match messages with "string" as a keyword 

q NEW - match new messages 

q OLD - match old messages 

q ON "date" - match messages with Date: matching "date" 

q RECENT - match messages with the WRECENT flag set 



q SEEN - match messages that have been read (the WSEEN flag is set) 

q SINCE "date" - match messages with Date: after "date" 

q SUBJECT "string" - match messages with "string" in the Subject: 

q TEXT "string" - match messages with text "string" 

q TO "string" - match messages with "string" in the To: 

q UNANSWERED - match messages that have not been answered 

q UNDELETED - match messages that are not deleted 

q UNFLAGGED - match messages that are not flagged 

q UNKEYWORD "string" - match messages that do not have the keyword "string" 

q UNSEEN - match messages which have not been read yet 

For example, to match all unanswered messages sent by Mom, you'd use: "UNANSWERED 
FROM mom". Searches appear to be case insensitive. This list of criteria is from a reading of the 
UW c-client source code and may be uncomplete or inaccurate. Searcher beware. 

Valid values for flags are SE_UID, which causes the returned array to contain UIDs instead of 
messages sequence numbers. 

Prev Home Next 

imap_msgno Up imap_last_error 



PHP Manual 

Prev Next 



imap_last_error 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_last_error ~ This function returns the last IMAP error (if any) that occurred during this page 
request. 



Description 



string imap_last_error(void ); 

This function returns the full text of the last IMAP error message that occurred on the current page. 
The error stack is untouched; calling imap_last_error() subsequently, with no intervening errors, 
will return the same error. 

Prev Home Next 

imap_search Ug imap_errors 



PHP Manual 

Prev Next 



imap_errors 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



imap_errors ~ This function returns all of the IMAP errors (if any) that have occurred during this 
page request or since the error stack was reset. 

Description 

array imap_errors(void ); 

This function returns an array of all of the IMAP error messages generated since the last 
imap_errors() call, or the beginning of the page. When imap_errors() is called, the error stack is 
subsequently cleared. 

Prev Home Next 

imap_last_error Ug imap_alerts 



PHP Manual 

Prev Next 



ibase connect 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_connect ~ 

Description 

ibase_connect( ); 



Prev Home Next 

InterBase functions U£ ibase_pconnect 



PHP Manual 

Prev Next 



ibase_pconnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_pconnect ~ 

Description 

ibase_pconnect( ); 



Prev Home Next 

ibase_connect U£ ibase_close 



PHP Manual 

Prev Next 



ibase close 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_close ~ 

Description 

ibase_close( ); 



Prev Home Next 

ibase_pconnect U£ ibase_query 



PHP Manual 

Prev Next 



ibase_query 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_query ~ 

Description 

ibase_query( ); 



Prev Home Next 

ibase_close U£ ibase_fetch_row 



PHP Manual 

Prev Next 



ibase fetch row 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_fetch_row ~ 

Description 

ibase_f etch_row( ); 



Prev Home Next 

ibase_query Ug ibase_free_result 



PHP Manual 

Prev Next 



ibase_free_result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ibase_free_result ~ 

Description 

ibase_f ree_result( ); 



Prev Home Next 

ibase_fetch_row U£ ibase_prepare 



PHP Manual 

Prev Next 



ibase_prepare 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_prepare ~ 

Description 

ibase_prepare( ); 



Prev Home Next 

ibase_free_result U£ ibase_bind 



PHP Manual 

Prev Next 



ibase bind 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_bind ~ 

Description 

ibase_bind( ); 



Prev Home Next 

ibase_prepare U£ ibase_execute 



PHP Manual 

Prev Next 



ibase execute 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_execute ~ 

Description 

ibase_execute( ); 



Prev Home Next 

ibase_bind U£ ibase_free_query 



PHP Manual 

Prev Next 



ibase_free_query 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_free_query ~ 

Description 

ibase_f ree_query( ); 



Prev Home Next 

ibase_execute U£ ibase_timefmt 



PHP Manual 

Prev Next 



ibase timefmt 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ibase_timefmt ~ 

Description 

ibase_timefmt( ); 



Prev Home Next 

ibase_free_query Ug LDAP functions 



PHP Manual 

Prev Next 



ldap_add 

■"his function is not supported in t^^^H 
Jh? Lite edition. ^M 

possible worka^aa^^aLii^S^y-t'lished. ] 

ldap_add — Add entries to LDAP directory 

Description 

int ldap_add(int link_identifier, string dn, array entry); 

returns true on success and false on error. 

The ldap_add() function is used to add entries in the LDAP directory. The DN of the entry to be added is 
specified by dn. Array entry specifies the information about the entry. The values in the entries are indexed by 
individual attributes. In case of multiple values for an attribute, they are indexed using integers starting with 0. 

entry["attributel"] = value 
entry ["attribute2"][0] = valuel 
entry["attribute2"][l] = value2 
Example 1. Complete example with authenticated bind 

<?php 

$ds=ldap_connect ( "localhost " ) ; // assuming the LDAP server is on this host 

if ($ds) { 

// bind with appropriate dn to give update access 
$r=ldap_bind ($ds, "cn=root , o=My Company, c=US", "secret"); 

// prepare data 

$info ["cn"]="John Jones"; 

$info [ "sn" ] =" Jones"; 

$inf o [ "mail" ] =" jon j@here . and . now" ; 

$info["objectclass"]="person"; 

// add data to directory 

$r=ldap_add ( $ds, "cn=John Jones, o=My Company, c=US", $info); 

ldap_close ($ds) ; 
} else { 

echo "Unable to connect to LDAP server"; 
} 
?> 

Prev Home Next 

LDAP functions IJp ldap_mod_add 



PHP Manual 

Prev Next 



ldap_mod_add 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_mod_add ~ Add attribute values to current attributes 

Description 

int ldap_mod_add(int Hnk_identifier, string dn, array entry); 

returns true on success and false on error. 

This function adds attribute(s) to the specified dn. It performs the modification at the attribute level 
as opposed to the object level. Object-level additions are done by the ldap_add() function. 

Prev Home Next 

ldap_add Ug ldap_mod_del 



PHP Manual 

Prev Next 



ldap_mod_del 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_mod_del ~ Delete attribute values from current attributes 

Description 

int ldap_mod_del(int link_identifier, string dn, array entry); 

returns true on success and false on error. 

This function removes attribute(s) from the specified dn. It performs the modification at the 
attribute level as opposed to the object level. Object-level deletions are done by the ldap_del() 
function. 

Prev Home Next 

ldap_mod_add Up ldap_mod_replace 



PHP Manual 

Prev Next 



ldap_mod_replace 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_mod_replace ~ Replace attribute values with new ones 

Description 

int ldap_mod_replace(int link_identifier, string dn, array entry); 

returns true on success and false on error. 

This function replaces attribute(s) from the specified dn. It performs the modification at the 
attribute level as opposed to the object level. Object-level modifications are done by the 
ldap_modify() function. 

Prev Home Next 

ldap_mod_del Up ldap_bind 



PHP Manual 

Prev Next 



ldap_bind 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_bind ~ Bind to LDAP directory 

Description 

int ldap_bind(int Hnk_identifier, string [bind_rdn], string [bind_pas sword]); 

Binds to the LDAP directory with specified RDN and password. Returns true on success and false 
on error. 

ldap_bind() does a bind operation on the directory. bind_rdn and bind_password are optional. If 
not specified, anonymous bind is attempted. 

Prev Home Next 

ldap_mod_replace Up ldap_close 



PHP Manual 

Prev Next 



ldap_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_close ~ Close Hnk to LDAP server 

Description 

int ldap_close(int Hnk_identifier); 
Returns true on success, false on error. 



ldap_close() closes the link to the LDAP server that's associated with the specified 

link_iden tifi er. 

This call is internally identical to ldap_unbind() . The LDAP API uses the call ldap_unbind() , so 
perhaps you should use this in preference to ldap_close(). 

Prev Home Next 

ldap_bind U^ ldap_connect 



PHP Manual 

Prev Next 



ldap_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_connect ~ Connect to an LDAP server 

Description 

int ldap_connect(string [hostname], int [port]); 

Returns a positive LDAP hnk identifier on success, or false on error. 

ldap_connect() estabhshes a connection to a LDAP server on a specified hostname and port. 
Both the arguments are optional. If no arguments are specified then the link identifier of the already 
opened link will be returned. If only hostname is specified, then the port defaults to 389. 

Prev Home Next 

ldap_close Up ldap_count_entries 



PHP Manual 

Prev Next 



ldap_count_entries 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_count_entries ~ Count the number of entries in a search 

Description 

int ldap_count_entries(int Hnk_identifier, int result_identifier); 

Returns number of entries in the result or false on error. 

ldap_count_entries() returns the number of entries stored in the result of previous search 
operations. result_iden tifier identifies the internal Idap result. 

Prev Home Next 

ldap_connect U^ ldap_delete 



PHP Manual 

Prev Next 



ldap_delete 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_delete ~ Delete an entry from a directory 

Description 



int ldap_delete(int Hnk_identifier, string dn); 

Returns true on success and false on error. 

ldap_delete() function delete a particular entry in LDAP directory specified by dn. 

Prev Home Next 

ldap_count_entries U^ ldap_dn2ufn 



PHP Manual 

Prev Next 



Idap_dn2ufn 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_dn2ufn ~ Convert DN to User Friendly Naming format 

Description 

string ldap_dn2uf n(string dn); 

ldap_dn2ufn() function is used to turn a DN into a more user-friendly form, stripping off type 
names. 

Prev Home Next 

ldap_delete Up ldap_explode_dn 



PHP Manual 

Prev Next 



ldap_explode_dn 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_explode_dn ~ SpHts DN into its component parts 

Description 

array ldap_explode_dn (string dn, int with_attrib); 

ldap_explode_dn() function is used to spHt the a DN returned by ldap_get_dn() and breaks it up 
into its component parts. Each part is known as Relative Distinguished Name, or RDN. 
ldap_explode_dn() returns an array of all those components. with_attrib is used to request if 
the RDNs are returned with only values or their attributes as well. To get RDNs with the attributes 
(i.e. in attribute=value format) set with_attrib to and to get only values set it to 1. 

Prev Home Next 

ldap_dn2ufn Up ldap_first_attribute 



PHP Manual 

Prev Next 



ldap_first_attribute 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_first_attribute ~ Return first attribute 

Description 



string ldap_f irst_attribute(int Hnk_identifier, int result_entry_identifier, int 
ber_identifier); 

Returns the first attribute in the entry on success and false on error. 

Similar to reading entries, attributes are also read one by one from a particular entry. 
ldap_first_attribute() returns the first attribute in the entry pointed by the entry identifier. 
Remaining attributes are retrieved by calling ldap_next_attribute() successively. 
ber_identifier is the identifier to internal memory location pointer. It is passed by reference. 
The same ber_identifier is passed to the ldap_next_attribute() function, which modifies that 
pointer. 

see also ldap_get_attributes() 

Prev Home Next 

ldap_explode_dn Ug ldap_first_entry 



PHP Manual 

Prev Next 



ldap_first_entry 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_first_entry ~ Return first result id 

Description 



int ldap_f irst_entry(int Hnk_identifier, int result_identifier); 

Returns the result entry identifier for the first entry on success and false on error. 

Entries in the LDAP result are read sequentially using the ldap_first_entry() and 
ldap_next_entry() functions. ldap_first_entry() returns the entry identifier for first entry in the 
result. This entry identifier is then supplied to lap_next_entry() routine to get successive entries 
from the result. 

see also ldap_get_entries() . 

Prev Home Next 

ldap_first_attribute Ug ldap_free_result 



PHP Manual 

Prev Next 



ldap_free_result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_free_result ~ Free result memory 

Description 

int ldap_f ree_result(int result_identifier); 

Returns true on success and false on error. 

ldap_free_result() frees up the memory allocated internally to store the result and pointed by the 
result_identifier. All result memory will be automatically freed when the script terminates. 

Typically all the memory allocated for the Idap result gets freed at the end of the script. In case the 
script is making successive searches which return large result sets, ldap_free_result() could be 
called to keep the runtime memory usage by the script low. 

Prev Home Next 

ldap_first_entry U^ ldap_get_attributes 



PHP Manual 

Prev Next 



ldap_get_attributes 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_get_attributes ~ Get attributes from a search result entry 

Description 

array 1 dap_g e t _a ttributes (int Hnk_identifier, int result_entry_identifier) ; 

Returns a complete entry information in a multi-dimensional array on success and false on error. 

ldap_get_attributes() function is used to simplify reading the attributes and values from an entry 
in the search result. The return value is a multi-dimensional array of attributes and values. 

Having located a specific entry in the directory, you can find out what information is held for that 
entry by using this call. You would use this call for an application which "browses" directory 
entries and/or where you do not know the structure of the directory entries. In many applications 
you will be searching for a specific attribute such as an email address or a surname, and won't care 
what other data is held. 

return_value[ "count"] = number of attributes in the entry 
return_value[0] = first attribute 
return_value[n] = nth attribute 

retum_value["attribute"] ["count"] = number of values for attribute 
return_value [" attribute "][0] = first value of the attribute 
return_value [" attribute "][i] = ith value of the attribute 



Example 1. Show the hst of attributes held for a particular directory entry 

// $ds is the link identifier for the directory 

// $sr is a valid search result from a prior call to 
// one of the Idap directory search calls 

$entry = ldap_f irst_entry ( $ds, $sr) ; 

$attrs = ldap_get_attributes ($ds, $entry) ; 

echo $attrs [ "count "]. " attributes held for this entry:<p>"; 

for ($1=0; $i<$attrs ["count"] ; $i++) 
echo $attrs [ $1] . "<br>" ; 

see also ldap_first_attribute() and ldap_next_attribute() 

Prey Home Next 

ldap_free_result Ug ldap_get_dn 



PHP Manual 

Prev Next 



ldap_get_dn 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_get_dn ~ Get the DN of a result entry 

Description 

string 1 dap_g e t _dn (int Hnk_identifier, int result_entry_identifier) ; 

Returns the DN of the result entry and false on error. 

ldap_get_dn() function is used to find out the DN of an entry in the result. 

Prev Home Next 

ldap_get_attributes U^ ldap_get_entries 



PHP Manual 

Prev Next 



ldap_get_entries 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_get_entries ~ Get all result entries 

Description 



array ldap_get_entries(int link_identifier, int result_identifier); 

Returns a complete result information in a multi-dimenasional array on success and false on error. 

ldap_get_entries() function is used to simplify reading multiple entries from the result and then 
reading the attributes and multiple values. The entire information is returned by one function call in 
a multi-dimensional array. The structure of the array is as follows. 

The attribute index is converted to lowercase. (Attributes are case-insensitive for directory servers, 
but not when used as array indices) 

return_value[ "count"] = number of entries in the result 
return_value[0] : refers to the details of first entry 

return_value[i]["dn"] = DN of the ith entry in the result 

return_value[i] ["count"] = number of attributes in ith entry 
return_value[i][j] = jth attribute in the ith entry in the result 

return_value[i] ["attribute"] ["count"] = number of values for 

attribute in ith entry 
return_value[i] ["attribute"] [j] = jth value of attribute in ith entry 

see also ldap_first_entry() and ldap_next_entry() 

Prev Home Next 

ldap_get_dn Up ldap_get_values 



PHP Manual 

Prev Next 



ldap_get_values 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_get_values ~ Get all values from a result entry 

Description 



array ldap_get_values(int link_identifier, int result_entry_identifier, string attribute); 

Returns an array of values for the attribute on success and false on error. 

ldap_get_values() function is used to read all the values of the attribute in the entry in the result, 
entry is specified by the result_entry_identifier. The number of values can be found by 
indexing "count" in the resultant array. Individual values are accessed by integer index in the array. 
The first index is 0. 

This call needs a result_entry_identifier, so needs to be preceded by one of the Idap 
search calls and one of the calls to get an individual entry. 

You application will either be hard coded to look for certain attributes (such as "surname" or 
"mail") or you will have to use the ldap_get_attributes() call to work out what attributes exist for a 
given entry. 

LDAP allows more than one entry for an attribute, so it can, for example, store a number of email 
addresses for one person's directory entry all labeled with the attribute "mail" 

return_value[ "count"] = number of values for attribute 
return_value[0] = first value of attribute 
return_value[i] = ith value of attribute 



Example 1. List all values of the "mail" attribute for a directory entry 

// $ds is a valid link identifier for a directory server 

// $sr is a valid search result from a prior call to 
// one of the Idap directory search calls 

// $entry is a valid entry identifier from a prior call to 
// one of the calls that returns a directory entry 

$values = ldap_get_values ($ds, $entry, "mail" ) ; 

echo $values [ "count "]. " email addresses for this entry. <p>"; 

for ($1=0; $i < $values [ "count "] ; $i++) 
echo $values [$i] . "<br>" ; 

Prev Home Next 

ldap_get_entries U^ ldap_get_values_len 



PHP Manual 

Prev Next 



ldap_get_values_len 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_get_values_len ~ Get all binary values from a result entry 

Description 

array ldap_get_values_len(int link_identifier, int result_entry_identifier, string 
attribute); 

Returns an array of values for the attribute on success and false on error. 

ldap_get_values_len() function is used to read all the values of the attribute in the entry in the 
result, entry is specified by the result_entry_identifier. The number of values can be 
found by indexing "count" in the resultant array. Individual values are accessed by integer index in 
the array. The first index is 0. 

This function is used exactly like ldap_get_values() except that it handles binary data and not 
string data. 

Prev Home Next 

ldap_get_values U£ ldap_list 



PHP Manual 

Prev Next 



Idapjist 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Idapjist ~ Single-level search 

Description 



int ldap_list(int link_identifier, string base_dn, string filter, array [attributes]); 

Returns a search result identifier or false on error. 

ldap_list() performs the search for a specified filter on the directory with the scope 
LDAP_SCOPE_ONELEVEL. 

LDAP_SCOPE_ONELEVEL means that the search should only return information that is at the 
level immediately below the base dn given in the call. (Equivalent to typing "Is" and getting a list of 
files and folders in the current working directory.) 

This call takes an optional fourth parameter which is an array of the attributes required. See 
ldap_search() notes. 

Example 1. Produce a list of all organizational units of an organization 

// $ds is a valid link identifier for a directory server 

$basedn = "o=My Company, c=US"; 
$justthese = array ("ou"); 

$sr=ldap_list ($ds, $basedn, "ou=*", $justthese); 

$info = ldap_get_entries ( $ds, $sr) ; 

for ($1=0; $i<$info ["count"] ; $1++) 
echo $info[$i] ["ou"] [0] ; 

Prev Home Next 

ldap_get_values_len Up ldap_modify 



PHP Manual 

Prev Next 



ldap_modify 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_modify ~ Modify an LDAP entry 

Description 

int ldap_modif y(int Hnk_identifier, string dn, array entry); 

Returns true on success and false on error. 

ldap_modify() function is used to modify the existing entries in the LDAP directory. The structure 
of the entry is same as in ldap_add() . 

Prev Home Next 

ldap_Hst Ug ldap_next_attribute 



PHP Manual 

Prev Next 



ldap_next_attribute 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_next_attribute ~ Get the next attribute in result 

Description 



string ldap_next_attribute(int Hnk_identifier, int result_entry_identifier, int 
ber_identifier); 

Returns the next attribute in an entry on success and false on error. 

ldap_next_attribute() is called to retrieve the attributes in an entry. The internal state of the 
pointer is maintained by the ber_identifier. It is passed by reference to the function. The first 
call to ldap_next_attribute() is made with the result_entry_identifier returned from 
ldap_first_attribute() . 

see also ldap_get_attributes() 

Prev Home Next 

ldap_modify U^ ldap_next_entry 



PHP Manual 

Prev Next 



ldap_next_entry 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_next_entry ~ Get next result entry 

Description 

int ldap_next_entry(int Hnk_identifier, int result_entry_identifier); 

Returns entry identifier for the next entry in the result whose entries are being read starting with 
ldap_first_entry . If there are no more entries in the result then it returns false. 

ldap_next_entry() function is used to retrieve the entries stored in the result. Successive calls to 
the ldap_next_entry() return entries one by one till there are no more entries. The first call to 
ldap_next_entry() is made after the call to ldap_first_entry() with the result_identifier as returned 
from the ldap_first_entry () . 

see also ldap_get_entries() 

Prev Home Next 

ldap_next_attribute Up ldap_read 



PHP Manual 

Prev Next 



ldap_read 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ldap_read ~ Read an entry 

Description 

int ldap_read(int Hnk_identifier, string base_dn, string filter, array [attributes]); 

Returns a search result identifier or false on error. 

ldap_read() performs the search for a specified filter on the directory with the scope 
LDAP_SCOPE_BASE. So it is equivalent to reading an entry from the directory. 

An empty filter is not allowed. If you want to retrieve absolutely all information for this entry, use a 
filter of "objectClass=*". If you know which entry types are used on the directory server, you might 
use an appropriate filter such as "objectClass=inetOrgPerson". 

This call takes an optional fourth parameter which is an array of the attributes required. See 
ldap_search() notes. 

Prev Home Next 

ldap_next_entry Up ldap_search 



PHP Manual 

Prev Next 



ldap_search 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



ldap_search ~ Search LDAP tree 

Description 

int ldap_search(int Hnk_identifier, string base_dn, string filter, array [attributes]); 

Returns a search result identifier or false on error. 

ldap_search() performs the search for a specified filter on the directory with the scope of 
LDAP_SCOPE_SUBTREE. This is equivalent to searching the entire directory. base_dn 
specifies the base DN for the directory. 

There is a optional fourth parameter, that can be added to restrict the attributes and values returned 
by the server to just those required. This is much more efficient than the default action (which is to 
return all attributes and their associated values). The use of the fourth parameter should therefore be 
considered good practice. 

The fourth parameter is a standard PHP string array of the required attributes, eg 
array("mail","sn","cn") Note that the "dn" is always returned irrespective of which attributes types 
are requested. 

Note too that some directory server hosts will be configured to return no more than a preset number 
of entries. If this occurs, the server will indicate that it has only returned a partial results set. 

The search filter can be simple or advanced, using boolean operators in the format described in the 
LDAP doumentation (see the Netscape Directory SDK for full information on filters). 

The example below retrieves the organizational unit, surname, given name and email address for all 
people in "My Company" where the surname or given name contains the substring $person. This 
example uses a boolean filter to tell the server to look for information in more than one attribute. 



Example 1. LDAP search 

// $ds is a valid link identifier for a directory server 

// $person is all or part of a person's name, eg "Jo" 

$dn = "o=My Company, c=US"; 

$filter=" ( I (sn=$person* ) (givenname=$person* ) ) " ; 

$justthese = array ( "ou", "sn", "givenname", "mail"); 

$sr=ldap_search ($ds, $dn, $f liter, $ justthese) ; 

$info = ldap_get_entries ( $ds, $sr) ; 

print $inf o [ "count "]. " entries returned<p>" ; 

Prev Home Next 

ldap_read U^ ldap_unbind 



PHP Manual 

Prev Next 



ldap_unbind 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

ldap_unbind ~ Unbind from LDAP directory 

Description 

int ldap_unbind(int Hnk_identifier); 
Returns true on success and false on error. 
ldap_unbind() function unbinds from the LDAP directory. 

Prev Home Next 

ldap_search Ug ldap_err2str 



PHP Manual 

Prev Next 



mcal_open 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_open ~ Opens up an MCAL connection 

Description 



int mcal_open(string calendar, string username, string password, string options); 

Returns an MCAL stream on success, false on error. 

mcal_open() opens up an MCAL connection to the specified calendar store. If the optional 
options is specified, passes the options to that mailbox also. The streams internal event 
structure is also initialized upon connection. 

Prev Home Next 

MCAL functions Up mcal_close 



PHP Manual 

Prev Next 



mcal_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_close ~ Close an MCAL stream 

Description 

int mcal_close(int mcal_stream, int flags); 
Closes the given meal stream. 



Prev Home Next 

mcal_open Up mcal_fetch_event 



PHP Manual 

Prev Next 



mcal_fetch_event 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_fetch_event ~ Fetches an event from the calendar stream 

Description 

object mcal_f etch_event(int mcal_stream, int event_id, int options); 
mcal_fetch_event() fetches an event from the calendar stream specified by i d. 
Returns an event object consisting of: 

q int id - ID of that event. 

q int public - TRUE if the event if public, FALSE if it is private. 

q string category - Category string of the event. 

q string title - Title string of the event. 

q string description - Description string of the event. 

q int alarm - number of minutes before the event to send an alarm/reminder. 

q object start - Object containing a datetime entry. 

q object end - Object containing a datetime entry. 

q int recur_type - recurrence type 

q int recur_interval - recurrence interval 

q datetime recur_endate - recurrence end date 

q int recur_data - recurrence data 
All datetime entries consist of an object that contains: 

q int year - year 

q int month - month 



q int mday - day of month 

q int hour - hour 

q int min - minutes 

q int sec - seconds 

q int alarm - minutes before event to send an alarm 



Prev Home Next 

mcal_close U^ mcal_list_events 



PHP Manual 

Prev Next 



mcal_list_events 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_Hst_events ~ Return a Hst of events between two given datetimes 

Description 

array mcal_list_events(int mcal_stream, int [begin_year] , int [begin_month] , int 
[begin_day] , int [end_year] , int [end_month] , int [end_day] ); 

Returns an array of event ID's that are between the start and end dates, or if just a stream is given, 
uses the start and end dates in the global event structure. 

mcal_list_events() function takes in an optional beginning date and an end date for a calendar 
stream. An array of event id's that are between the given dates or the internal event dates are 
returned. 

Prev Home Next 

mcal_fetch_event Up mcal_store_event 



PHP Manual 

Prev Next 



mcal_store_event 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_store_event ~ Store an event into an MCAL calendar 

Description 

int mcal_store_event(int mcal_stream); 

mcal_store_event() Stores the global event into an MCAL calendar for the given stream. 

Returns true on success and false on error. 

Prev Home Next 

mcal_list_events U^ mcal_delete_event 



PHP Manual 

Prev Next 



mcal_delete_event 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_delete_event ~ Delete an event from an MCAL calendar 

Description 

int mcal_delete_event(int uid); 

mcal_delete_event() deletes the calendar event specified by the uid. 

Returns true. 

Prev Home Next 

mcal_store_event U^ mcal_snooze 



PHP Manual 

Prev Next 



mcal_snooze 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_snooze ~ Turn off an alarm for an event 

Description 

int mcal_snooze(int uid); 

mcal_snooze() turns off an alarm for a calendar event specified by the uid. 

Returns true. 

Prev Home Next 

mcal_delete_event U^ mcal_list_alarms 



PHP Manual 

Prev Next 



meal list alarms 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_Hst_alarms ~ Return a Hst of events that has an alarm triggered at the given datetime 

Description 

array mcal_list_events(int mcal_stream, int [begin_year] , int [begin_month] , int 
[begin_day] , int [end_year] , int [end_month] , int [end_day] ); 

Returns an array of event ID's that has an alarm going off between the start and end dates, or if just 
a stream is given, uses the start and end dates in the global event structure. 

mcal_list_events() function takes in an optional beginning date and an end date for a calendar 
stream. An array of event id's that are between the given dates or the internal event dates are 
returned. 

Prev Home Next 

mcal_snooze Up mcal_event_init 



PHP Manual 

Prev Next 



mcal_event_init 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_event_init ~ InitiaHzes a streams global event structure 

Description 

int mcal_event_init(int stream); 

mcal_event_init() initializes a streams global event structure, this effectively sets all elements of 
the structure to 0, or the default settings. 

Returns true. 

Prev Home Next 

mcal_list_alarms U^ mcal_event_set_category 



PHP Manual 

Prev Next 



mcal_event_set_category 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_category ~ Sets the category of the streams global event structure 

Description 

int mcal_event_set_category(int stream, string category); 

mcal_event_set_category() sets the streams global event structure's category to the given string. 
Returns true. 

Prev Home Next 

mcal_event_init U^ mcal_event_set_title 



PHP Manual 

Prev Next 



mcal_event_set_title 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_event_set_title ~ Sets the title of the streams global event structure 

Description 

int mcal_event_set_title(int stream, string title); 

mcal_event_set_title() sets the streams global event structure's title to the given string. 

Returns true. 

Prev Home Next 

mcal_event_set_category Ug mcal_event_set_description 



PHP Manual 

Prev Next 



mcal_event_set_description 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_description — Sets the description of the streams global event structure 

Description 

int mcal_event_set_description (int stream, string description); 

mcal_event_set_description() sets the streams global event structure's description to the given 
string. 

Returns true. 

Prev Home Next 

mcal_event_set_title U^ mcal_event_set_start 



PHP Manual 

Prev Next 



mcal_event_set_start 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_event_set_start ~ Sets the start date and time of the streams global event structure 

Description 

int mcal_event_set_start(int stream, int year, int month, int [day] , int [hour] , int [min] , 
int [sec] ); 

mcal_event_set_start() sets the streams global event structure's start date and time to the given 
values. 

Returns true. 

Prev Home Next 

mcal_event_set_description Up mcal_event_set_end 



PHP Manual 

Prev Next 



mcal_event_set_end 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_event_set_end ~ Sets the end date and time of the streams global event structure 

Description 

int mcal_event_set_end(int stream, int year, int month, int [day] , int [hour] , int [min] , int 

[sec] ); 

mcal_event_set_end() sets the streams global event structure's end date and time to the given 
values. 

Returns true. 

Prev Home Next 

mcal_event_set_start Up mcal_event_set_alarm 



PHP Manual 

Prev Next 



mcal_event_set_alarm 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_event_set_alarm ~ Sets the alarm of the streams global event structure 

Description 

int mcal_event_set_alarm(int stream, int alarm); 

mcal_event_set_alarm() sets the streams global event structure's alarm to the given minutes before 
the event. 

Returns true. 

Prev Home Next 

mcal_event_set_end U^ mcal_event_set_class 



PHP Manual 

Prev Next 



mcal_event_set_class 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_event_set_class ~ Sets the class of the streams global event structure 

Description 

int mcal_event_set_class(int stream, int class); 

mcal_event_set_dass() sets the streams global event structure's class to the given value. The class 
is either for public, or 1 for private. 

Returns true. 

Prev Home Next 

mcal_event_set_alarm Ug mcal_is_leap_year 



PHP Manual 

Prev Next 



mcal_is_leap_year 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_is_leap_year — Returns if the given year is a leap year or not 

Description 

int mcal_is_leap_year(int year); 

mcal_is_leap_year() returns 1 if the given year is a leap year, 1 if not. 

Prev Home Next 

mcal_event_set_class Up mcal_days_in_month 



PHP Manual 

Prev Next 



mcal_days_in_month 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_days_in_month ~ Returns the number of days in the given month 

Description 

int mcal_days_in_month(int month, int leap year); 

mcal_days_in_month() Returns the number of days in the given month, taking into account if the 
given year is a leap year or not. 

Prev Home Next 

mcal_is_leap_year Up mcal_date_valid 



PHP Manual 

Prev Next 



mcal_date_valid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_date_vaHd ~ Returns true if the given year, month, day is a vaHd date 

Description 

int mcal_date_valid(int year, int month, int day); 

mcal_date_valid() Returns true if the given year, month and day is a vahd date, false if not. 

Prev Home Next 

mcal_days_in_month Up mcal_time_vaHd 



PHP Manual 

Prev Next 



mcal_time_valid 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_time_vaHd ~ Returns true if the given year, month, day is a vaHd time 

Description 

int mcal_time_valid(int hour, int minutes, int seconds); 

mcal_time_valid() Returns true if the given hour, minutes and seconds is a vahd time, false if not. 

Prev Home Next 

mcal_date_vahd Up mcal_day_of_week 



PHP Manual 

Prev Next 



mcal_day_of_week 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_day_of_week ~ Returns the day of the week of the given date 

Description 

int mcal_(int year, int month, int day); 

mcal_day_of_week() returns the day of the week of the given date 

Returns true. 

Prev Home Next 

mcal_time_valid U^ mcal_day_of_year 



PHP Manual 

Prev Next 



mcal_day_of_year 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_day_of_year ~ Returns the day of the year of the given date 

Description 

int mcal_(int year, int month, int day); 
mcal_day_of_year() returns the day of the year of the given date 
Returns true. 

Prev Home Next 

mcal_day_of_week Ug mcal_date_compare 



PHP Manual 

Prev Next 



mcal_date_compare 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_date_compare ~ Compares two dates 

Description 



int mcal_date_compare(int a_year, int a_month, int a_day, int b_year, int b_month, int 
b_day); 

mcal_date_compare() Compares the two given dates, returns <0, 0, >0 if a<b, a==b, a>b 
respectively 

Prev Home Next 

mcal_day_of_year U^ mcal_next_recurrence 



PHP Manual 

Prev Next 



mcal_next_recurrence 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mcal_next_recurrence ~ Returns the next recurrence of the event 

Description 

int mcal_next_recurrence(int stream, int weekstart, array next); 

mcal_next_recurrence() returns an object filled with the next date the event occurs, on or after the 
supplied date. Returns empty date field if event does not occur or something is invalid. Uses 
weekstart to determine what day is considered the beginning of the week. 

Returns true. 

Prev Home Next 

mcal_date_compare Up mcal_event_set_recur_daily 



PHP Manual 

Prev Next 



mcal_event_set_recur_daily 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_recur_daily ~ Sets the recurrence of the streams global event structure 

Description 

int mcal_event_set_recur_daily (int stream, int year, int month, int day, int hour, int 
min, int sec, int interval); 

mcal_event_set_recur_daily() sets the streams global event structure's recurrence to the given 
value to be reoccuring on a daily basis, ending at the given date. 

Prev Home Next 

mcal_next_recurrence Ug mcal_event_set_recur_weekly 



PHP Manual 

Prev Next 



mcal_event_set_recur_weekly 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_recur_weekly — Sets the recurrence of the streams global event structure 

Description 

int mcal_event_set_recur_weekly (int stream, int year, int month, int day, int hour, int 
min, int sec, int interval, int weekdays); 

mcal_event_set_recur_weekly() sets the streams global event structure's recurrence to the given 
value to be reoccuring on a weekly basis, ending at the given date. 

Prev Home Next 

mcal_event_set_recur_daily Up mcal_event_set_recur_monthly_mday 



PHP Manual 

Prev Next 



mcal_event_set_recur_monthly_mday 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_recur_monthly_mday ~ Sets the recurrence of the streams global event structure 

Description 

int mcal_event_set_recur_monthly_mday (int stream, int year, int month, int day, int 
hour, int min, int sec, int interval); 

mcal_event_set_recur_monthly_mday() sets the streams global event structure's recurrence to the 
given value to be reoccuring on a monthly by month day basis, ending at the given date. 

Prev Home Next 

mcal_event_set_recur_weekly Up mcal_event_set_recur_monthly_wday 



PHP Manual 

Prev Next 



mcal_event_set_recur_monthly_wday 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_recur_monthly_wday ~ Sets the recurrence of the streams global event structure 

Description 

int mcal_event_set_recur_monthly_wday (int stream, int year, int month, int day, int 
hour, int min, int sec, int interval); 

mcal_event_set_recur_monthly_wday() sets the streams global event structure's recurrence to the 
given value to be reoccuring on a monthly by week basis, ending at the given date. 

Prev Home Next 

mcal_event_set_recur_monthly_mday Up mcal_event_set_recur_yearly 



PHP Manual 

Prev Next 



mcal_event_set_recur_yearly 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_event_set_recur_yearly ~ Sets the recurrence of the streams global event structure 

Description 

int mcal_event_set_recur_yearly (int stream, int year, int month, int day, int hour, int 
min, int sec, int interval); 

mcal_event_set_recur_yearly() sets the streams global event structure's recurrence to the given 
value to be reoccuring on a yearly basis,ending at the given date . 

Prev Home Next 

mcal_event_set_recur_monthly_wday Up mcal_fetch_current_stream_event 



PHP Manual 

Prev Next 



meal fetch current stream event 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mcal_fetch_current_stream_event ~ Returns an object containing the current streams event 
structure 



Description 



int mcal_f etch_current_stream_event (int stream); 

mcal_event_fetch_current_stream_event() returns the current stream's event structure as an 
object containing: 

q int id - ID of that event. 

q int pubHc - TRUE if the event if pubHc, FALSE if it is private. 

q string category - Category string of the event. 

q string title - Title string of the event. 

q string description - Description string of the event. 

q int alarm - number of minutes before the event to send an alarm/reminder. 

q object start - Object containing a datetime entry. 

q object end - Object containing a datetime entry. 

q int recur_type - recurrence type 

q int recur_interval - recurrence interval 

q datetime recur_endate - recurrence end date 

q int recur_data - recurrence data 
All datetime entries consist of an object that contains: 

q int year - year 

q int month - month 



q int mday - day of month 

q int hour - hour 

q int min - minutes 

q int sec - seconds 

q int alarm - minutes before event to send an alarm 



Prev 
mcal_event_set_recur_yearly 



Home 



Next 
Microsoft SQL Server functions 



PHP Manual 

Prev Next 



mssql_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_close ~ close MS SQL Server connection 

Description 

int mssql_close(int Hnk_identifier); 

Returns: true on success, false on error 

mssql_close() closes the link to a MS SQL Server database that's associated with the specified link 
identifier. If the link identifier isn't specified, the last opened link is assumed. 

Note that this isn't usually necessary, as non-persistent open links are automatically closed at the 
end of the script's execution. 

mssql_close() will not close persistent links generated by mssql_pconnect(). 

See also: mssql_connect() , mssql_pconnect() . 

Prev Home Next 

Microsoft SQL Server functions Ug mssql_connect 



PHP Manual 

Prev Next 



mssq l_data_seek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_data_seek — move internal row pointer 

Description 

int ms sql_dat a_seek(int result_identifier, int row_number); 

Returns: true on success, false on failure 

mssql_data_seek() moves the internal row pointer of the MS SQL result associated with the 
specified result identifier to pointer to the specifyed row number. The next call to 
mssql_fetch_row() would return that row. 

See also: mssql_data_seek(). 

Prev Home Next 

mssql_connect Up mssql_fetch_array 



PHP Manual 

Prev Next 



mssql_fetch_array 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_fetch_array ~ fetch row as array 

Description 



int mssql_f etch_array(int result); 

Returns: An array that corresponds to the fetched row, or false if there are no more rows. 

mssql_fetch_array() is an extended version of mssql_f etch_ro w() . In addition to storing the data in 
the numeric indices of the result array, it also stores the data in associative indices, using the field 
names as keys. 

An important thing to note is that using mssql_fetch_array() is NOT significantly slower than using 
mssql_fetch_row(), while it provides a significant added value. 

For further details, also see mssql_fetch_row() 

Prev Home Next 

mssql_data_seek Up mssql_fetch_field 



PHP Manual 

Prev Next 



mssql_fetch_field 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_fetch_field ~ get field information 

Description 

object mssql_fetch_field(int result, int field_offset); 

Returns an object containing field information. 

mssql_fetch_field() can be used in order to obtain information about fields in a certain query result. 
If the field offset isn't specified, the next field that wasn't yet retreived by mssql_fetch_field() is 
retreived. 

The properties of the object are: 

q name - column name, if the column is a result of a function, this property is set to 
computed#N, where #N is a serial number. 

q column_source - the table from which the column was taken 

q max_length - maximum length of the column 

q numeric - 1 if the column is numeric 

See also mssql_field_seek() 

Prev Home Next 

mssql_fetch_array Up mssql_fetch_object 



PHP Manual 

Prev Next 



mssql_fetch_obiect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_fetch_object ~ fetch row as object 

Description 

int mssql_f etch_ob ject(int result); 

Returns: An object with properties that correspond to the fetched row, or false if there are no more 
rows. 

mssql_fetch_object() is similar to mssq l_f etch_ar ray () , with one difference - an object is returned, 
instead of an array. Indirectly, that means that you can only access the data by the field names, and 
not by their offsets (numbers are illegal property names). 

Speed-wise, the function is identical to mssql_fetch_array() , and almost as quick as 
mssql_fetch_row() (the difference is insignificant). 

See also: mssql_fetch-array() and mssql_fetch-row() . 

Prev Home Next 

mssql_fetch_field U^ mssql_fetch_row 



PHP Manual 

Prev Next 



mssq l_f etch_row 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_fetch_row ~ get row as enumerated array 

Description 



array mssql_f etch_row(int result); 

Returns: An array that corresponds to the fetched row, or false if there are no more rows. 

mssql_fetch_row() fetches one row of data from the result associated with the specified result 
identifier. The row is returned as an array. Each result column is stored in an array offset, starting at 
offset 0. 

Subsequent call to mssql_fetch_rows() would return the next row in the result set, or false if there 
are no more rows. 

See also: mssql_fetch_array() , mssql_fetch_object() , mssql_data_seek() , 
mssql_fetch_lengths(), and mssql_result() . 

Prev Home Next 

mssql_fetch_object Up mssql_field_seek 



PHP Manual 

Prev Next 



mssql_field_seek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_field_seek ~ set field offset 

Description 

int mssql_f ield_seek(int result, int field_offset); 

Seeks to the specified field offset. If the next call to mssql_fetch_field() won't include a field 
offset, this field would be returned. 

See also: mssql_fetch_field() . 

Prev Home Next 

mssql_fetch_row U^ mssql_free_result 



PHP Manual 

Prev Next 



mssq l_f ree_resu It 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_free_result ~ free result memory 

Description 

int mssql_f ree_result(int result); 

mssql_free_result() only needs to be called if you are worried about using too much memory while 
your script is running. All result memory will automatically be freed when the script, you may call 
mssql_free_result() with the result identifier as an argument and the associated result memory will 
be freed. 

Prev Home Next 

mssql_field_seek Ug mssql_num_fields 



PHP Manual 

Prev Next 



mssql_num_fields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_num_fields ~ get number of fields in result 

Description 



int mssql_num_fields(int result); 

mssql_num_fields() returns the number of fields in a result set. 

See also: mssql_db_query(), mssql_query() , mssql_fetch_field() , mssql_num_rows() . 

Prev Home Next 

mssql_free_result U^ mssql_num_rows 



PHP Manual 

Prev Next 



mssql_num_rows 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mssql_num_rows ~ get number of rows in result 

Description 

int mssql_num_rows(string result); 

mssql_num_rows() returns the number of rows in a result set. 

See also: mssql_db_query(), mssql_query() and, mssql_fetch_row() . 

Prev Home Next 

mssql_num_fields U^ mssql_pconnect 



PHP Manual 

Prev Next 



msql 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



msql ~ send mSQL query 

Description 

int msql (string database, string query, int Hnk_identifier); 

Returns a positive mSQL query identifier to the query result, or false on error. 

msql() selects a database and executes a query on it. If the optional link identifier isn't specified, the 
function will try to find an open link to the mSQL server and if no such link is found it'll try to 
create one as if msql_connect() was called with no arguments (see msql_connect() ). 

Prev Home Next 

mSQL functions Up msql_affected_rows 



PHP Manual 

Prev Next 



msql_affected_rows 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_affected_rows ~ returns number of affected rows 

Description 

int msql_af f ected_rows(int query _identifier); 

Returns number of affected ("touched") rows by a specific query (i.e. the number of rows returned 
by a SELECT, the number of rows modified by an update, or the number of rows removed by a 
delete). 

See also: msql_query() 

Prev Home Next 

msql Up msql_close 



PHP Manual 

Prev Next 



msql_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_close ~ close mSQL connection 

Description 

int msql_close(int Hnk_identifier); 

Returns true on success, false on error. 

msql_close() closes the link to a mSQL database that's associated with the specified link identifier. 
If the link identifier isn't specified, the last opened link is assumed. 

Note that this isn't usually necessary, as non-persistent open links are automatically closed at the 
end of the script's execution. 

msql_close() will not close persistent links generated by msql_pconnect() . 
See also: msql_connect() and msql_pconnect() . 

Prev Home Next 

msql_affected_rows Ug msql_connect 



PHP Manual 

Prev Next 



msql_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_connect ~ open mSQL connection 

Description 

int msql_connect(string hostname); 

Returns a positive mSQL Hnk identifier on success, or false on error. 

msql_connect() estabhshes a connection to a mSQL server. The hostname argument is optional, and 
if it's missing, localhost is assumed. 

In case a second call is made to msql_connect() with the same arguments, no new link will be 
established, but instead, the link identifier of the already opened link will be returned. 

The link to the server will be closed as soon as the execution of the script ends, unless it's closed 
earlier by explicitly calling msql_close() . 

See also msql_pconnect() , msql_dose() . 

Prev Home Next 

msql_close Up msql_create_db 



PHP Manual 

Prev Next 



msql_create_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_create_db ~ create mSQL database 

Description 

int msql_create_db(string database name, int [Hnk_identifier] ); 

msql_create_db() attempts to create a new database on the server associated with the specified Hnk 
identifier. 

See also: msql_drop_db() . 

Prev Home Next 

msql_connect Ug msql_createdb 



PHP Manual 

Prev Next 



msql_createdb 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_createdb ~ create mSQL database 

Description 

int msql_createdb(string database name, int [Hnk_identifier] ); 
Identical to msql_create_db() . 

Prev Home Next 

msql_create_db Up msql_data_seek 



PHP Manual 

Prev Next 



msql_data_seek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_data_seek ~ move internal row pointer 

Description 

int msql_data_seek(int query _identifier, int row_number); 

Returns true on success, false on failure. 

msql_data_seek() moves the internal row pointer of the mSQL result associated with the specified 
query identifier to pointer to the specifyed row number. The next call to msql_fetch_row() would 
return that row. 

See also: msql_fetch_row() . 

Prev Home Next 

msql_createdb Up msql_dbname 



PHP Manual 

Prev Next 



msql_dbname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_dbname ~ get current mSQL database name 

Description 

string msql_dbname(int query _identifier, int i); 

msql_dbname() returns the database name stored in position i of the result pointer returned from 
the msql_listdbs() function. The msql_numrows() function can be used to determine how many 
database names are available. 

Prev Home Next 

msql_data_seek Up msql_drop_db 



PHP Manual 

Prev Next 



msql_drop_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_drop_db ~ drop (delete) mSQL database 

Description 

int msql_drop_db(string database_name, int Hnk_identifier); 

Returns true on success, false on failure. 

msql_drop_db() attempts to drop (remove) an entire database from the server associated with the 
specified link identifier. 

See also: msql_create_db() . 

Prev Home Next 

msql_dbname Up msql_dropdb 



PHP Manual 

Prev Next 



msql_dropdb 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_dropdb ~ drop (delete) mSQL database 

Description 

See msql_drop_db(). 



Prev Home Next 

msql_drop_db Up msql_error 



PHP Manual 

Prev Next 



msql_error 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_error ~ returns error message of last msql call 

Description 

string msql_error( ); 

Errors coming back from the mSQL database backend no longer issue warnings. Instead, use these 
functions to retrieve the error string. 

Prev Home Next 

msql_dropdb Up msql_fetch_array 



PHP Manual 

Prev Next 



msql_fetch_array 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fetch_array ~ fetch row as array 

Description 



int msql_f etch_array(int query _identifier, int [result_type] ); 

Returns an array that corresponds to the fetched row, or false if there are no more rows. 

msql_fetch_array() is an extended version of msql_f etch_ro w() . In addition to storing the data in 
the numeric indices of the result array, it also stores the data in associative indices, using the field 
names as keys. 

The second optional argument result_type in msql_fetch_array() is a constant and can take 
the following values: MSQL_ASSOC, MSQL_NUM, and MYSQL_BOTH. 

Be careful if you are retrieving results from a query that may return a record that contains only one 
field that has a value of (or an empty string, or NULL). 

An important thing to note is that using msql_fetch_array() is NOT significantly slower than using 
msql_fetch_row() , while it provides a significant added value. 

For further details, also see msql_fetch_row() 

Prev Home Next 

msql_error Up msql_fetch_field 



PHP Manual 

Prev Next 



msql_fetch_field 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fetch_field ~ get field information 

Description 

object msql_f etch_f ield(int query_identifier, int field_offset); 

Returns an object containing field information 

msql_fetch_field() can be used in order to obtain information about fields in a certain query result. 
If the field offset isn't specified, the next field that wasn't yet retreived by msql_fetch_field() is 
retreived. 

The properties of the object are: 

q name - column name 

q table - name of the table the column belongs to 

q not_null - 1 if the column cannot be null 

q primary _key - 1 if the column is a primary key 

q unique - 1 if the column is a unique key 

q type - the type of the column 
See also msql_field_seek() . 

Prev Home Next 

msql_fetch_array Up msql_fetch_object 



PHP Manual 

Prev Next 



msql_fetch_obiect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fetch_object ~ fetch row as object 

Description 

int msql_f etch_ob ject(int query_identifier, int [result_type] ); 

Returns an object with properties that correspond to the fetched row, or false if there are no more 
rows. 

msql_fetch_object() is similar to msql_fetch_array() , with one difference - an object is returned, 
instead of an array. Indirectly, that means that you can only access the data by the field names, and 
not by their offsets (numbers are illegal property names). 

The optional second argument result_type in msql_fetch_array() is a constant and can take 
the following values: MSQL_ASSOC, MSQL_NUM, and MSQL_BOTH. 

Speed-wise, the function is identical to msql_fetch_array() , and almost as quick as 
msql_fetch_row() (the difference is insignificant). 

See also: msql_fetch_array() and msql_fetch_row() . 

Prev Home Next 

msql_fetch_field IJ£ msql_fetch_row 



PHP Manual 

Prev Next 



msql_fetch_row 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fetch_row ~ get row as enumerated array 

Description 



array msql_f etch_row(int query _identifier); 

Returns an array that corresponds to the fetched row, or false if there are no more rows. 

msql_fetch_row() fetches one row of data from the result associated with the specified query 
identifier. The row is returned as an array. Each result column is stored in an array offset, starting at 
offset 0. 

Subsequent call to msql_fetch_row() would return the next row in the result set, or false if there are 
no more rows. 

See also: msql_fetch_array() , msql_fetch_object() , msql_data_seek() , and msql_result() . 

Prev Home Next 

msql_fetch_object Up msql_fieldname 



PHP Manual 

Prev Next 



msql_fieldname 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fieldname ~ get field name 

Description 

string msql_f ieldname(int query _identifier, int field); 

msql_fieldname() returns the name of the specified field. query_identifier is the query 
identifier, and fieldis the field index. msql_f ieldname ( $result , 2 ) ; will return the 
name of the second field in the result associated with the result identifier. 

Prev Home Next 

msql_fetch_row Up msql_field_seek 



PHP Manual 

Prev Next 



msql_field_seek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_field_seek ~ set field offset 

Description 

i n t ms ql_f i e 1 d_s e e k(int query _identifier, int field_offset); 

Seeks to the specified field offset. If the next call to msql_fetch_field() won't include a field offset, 
this field would be returned. 

See also: msql_fetch_field() . 

Prev Home Next 

msql_fieldname U^ msql_fieldtable 



PHP Manual 

Prev Next 



msql_fieldtable 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fieldtable ~ get table name for field 

Description 

int msql_f ieldtable(int query _identifier, int field); 
Returns the name of the table field was fetched from. 



Prev Home Next 

msql_field_seek Up msql_fieldtype 



PHP Manual 

Prev Next 



msql_fieldtype 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fieldtype ~ get field type 

Description 

string msql_f ieldtype(int query _identifier, int i); 

msql_fieldtype() is similar to the msql_fieldname() function. The arguments are identical, but the 
field type is returned. This will be one of "int", "string" or "real". 

Prev Home Next 

msql_fieldtable Up msql_fieldflags 



PHP Manual 

Prev Next 



msql_fieldflags 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fieldflags ~ get field flags 

Description 

string msql_f ieldf lags(int query _identifier, int i); 

msql_fieldflags() returns the field flags of the specified field. Currently this is either, "not null", 
"primary key", a combination of the two or "" (an empty string). 

Prev Home Next 

msql_fieldtype Up msql_fieldlen 



PHP Manual 

Prev Next 



msql_fieldlen 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_fieldlen ~ get field length 

Description 

int msql_f ieldlen(int query _identifier, int i); 
msql_fieldlen() returns the length of the specified field. 



Prev Home Next 

msql_fieldflags Up msql_free_result 



PHP Manual 

Prev Next 



msql_free_result 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_free_result ~ free result memory 

Description 

int msql_f ree_result(int query _identifier); 

msql_free_result() frees the memory associated with query_identifier. When PHP 
completes a request, this memory is freed automatically, so you only need to call this function when 
you want to make sure you don't use too much memory while the script is running. 

Prev Home Next 

msql_fieldlen Up msql_freeresult 



PHP Manual 

Prev Next 



msql_freeresult 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_freeresult ~ free result memory 

Description 

See msql_free_result() 



Prev Home Next 

msql_free_result Up msql_Hst_fields 



PHP Manual 

Prev Next 



msql_list_fields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_Hst_fields ~ Hst result fields 

Description 

int msql_list_fields (string database, string tablename); 

msql_list_fields() retrieves information about the given tablename. Arguments are the database 
name and the table name. A result pointer is returned which can be used with msql_fieldflags() , 
msql_fieldlen() , msql_fieldname() , and msql_fieldtype() . A query identifier is a positive integer. 
The function returns -1 if a error occurs. A string describing the error will be placed in 
$phperrmsg, and unless the function was called as @msql_list_f ields ( ) then this error 
string will also be printed out. 

See also msql_error() . 

Prev Home Next 

msql_freeresult Ug msql_listfields 



PHP Manual 



Prev 



Next 



msqijistfi 



p 

F 



his function is not supported in the 
PHP Lite edition, 
ossible workaround not yet pubUsh 



|dJ 



msql_Hstfields ~ Hst result fields 

Description 



See msql_list_fields() . 



Prev 
msql_list_fields 



Home 
Up 



Next 
msql_list_dbs 



PHP Manual 

Prev Next 



msql_list_dbs 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_Hst_dbs ~ Hst mSQL databases on server 

Description 

int msql_list_dbs(void); 

msql_list_dbs() will return a result pointer containing the databases available from the current msql 
daemon. Use the msql_dbname() function to traverse this result pointer. 

Prev Home Next 

msql_listfields Up msql_listdbs 



PHP Manual 

Prev Next 



msqijistdbs 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msqijistdbs ~ Hst mSQL databases on server 

Description 

See msql_list_dbs(). 



Prev Home Next 

msql_Hst_dbs Up msql_Hst_tables 



PHP Manual 

Prev Next 



msql_list_tables 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_Hst_tables ~ Hst tables in an mSQL database 

Description 

int msql_list_tables(string database); 

msql_list_tables() takes a database name and result pointer much like the msqlQ function. The 
msql_tablename() function should be used to extract the actual table names from the result pointer. 

Prev Home Next 

msql_listdbs Up msql_listtables 



PHP Manual 

Prev Next 



msqijisttables 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msqijisttables ~ list tables in an mSQL database 

Description 

See msql_list_tables() . 



Prev Home Next 

msql_list_tables Up msql_num_fields 



PHP Manual 

Prev Next 



msql_num_fields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_num_fields ~ get number of fields in result 

Description 

i n t m s q 1 _n u m_ fields(int query _identifier) ; 

msql_num_fields() returns the number of fields in a result set. 

See also: msqlQ , msql_query() , msql_fetch_field() , and msql_num_rows() . 

Prev Home Next 

msql_listtables U^ msql_num_rows 



PHP Manual 

Prev Next 



msql_num_rows 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_num_rows ~ get number of rows in result 

Description 

int msql_num_rows(int query _identifier); 
msql_num_rows() returns the number of rows in a result set. 
See also: msqlQ , msql_query() , and msql_fetch_row() . 

Prev Home Next 

msql_num_fields Ug msql_numfields 



PHP Manual 

Prev Next 



msql_numfields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_numfields ~ get number of fields in result 

Description 



int msql_numf ields(int query _identifier); 
Identical to msql_num_fields() . 



Prev Home Next 

msql_num_rows Up msql_numrows 



PHP Manual 

Prev Next 



msql_numrows 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_numrows ~ get number of rows in result 

Description 



int msql_numrows(void); 
Identical to msql_num_rows() . 



Prev Home Next 

msql_numfields Up msql_pconnect 



PHP Manual 

Prev Next 



msql_pconnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msqLpconnect ~ open persistent mSQL connection 

Description 

int msql_pconnect(string hostname); 

Returns a positive mSQL persistent Hnk identifier on success, or false on error. 

msql_pconnect() acts very much Hke msql_connect() with two major differences. 

First, when connecting, the function would first try to find a (persistent) link that's already open 
with the same host. If one is found, an identifier for it will be returned instead of opening a new 
connection. 

Second, the connection to the SQL server will not be closed when the execution of the script ends. 
Instead, the link will remain open for future use ( msql_close() will not close links established by 
msql_pconnect()) . 

This type of links is therefore called 'persistent'. 

Prev Home Next 

msql_numrows U^ msql_query 



PHP Manual 

Prev Next 



msql_query 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



msqLquery — send mSQL query 

Description 

int msql_query(string query, int Hnk_identifier); 

msql_query() sends a query to the currently active database on the server that's associated with the 
specified Hnk identifier. If the Hnk identifier isn't specified, the last opened link is assumed. If no 
link is open, the function tries to establish a link as if msql_connect() was called, and use it. 

Returns a positive mSQL query identifier on success, or false on error. 
See also: msqlQ , msql_select_db() , and msql_connect() . 

Prev Home Next 

msqLpconnect Up msql_regcase 



PHP Manual 

Prev Next 



msql_regcase 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_regcase ~ make regular expression for case insensitive match 

Description 

See sql_regcase() . 

Prev Home Next 

msqLquery Up msql_result 



PHP Manual 

Prev Next 



msql_result 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



msql_result ~ get result data 

Description 

int msql_result(int query_identifier, int i, mixed field); 

Returns the contents of the cell at the row and offset in the specified mSQL result set. 

msql_result() returns the contents of one cell from a mSQL result set. The field argument can be the 
field's offset, or the field's name, or the field's table dot field's name (fieldname.tablename). If the 
column name has been aliased ('select foo as bar from...'), use the alias instead of the column name. 

When working on large result sets, you should consider using one of the functions that fetch an 
entire row (specified below). As these functions return the contents of multiple cells in one function 
call, they're MUCH quicker than msql_result(). Also, note that specifying a numeric offset for the 
field argument is much quicker than specifying a fieldname or tablename.fieldname argument. 

Recommended high-performance alternatives: msql_fetch_row() , msql_fetch_array() , and 
msql_fetch_object() . 

Prev Home Next 

msql_regcase Up msql_select_db 



PHP Manual 

Prev Next 



msql_select_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_select_db ~ select mSQL database 

Description 

i n t ms ql_s e 1 e c t_db(string database_name, int Hnk_identifier); 

Returns true on success, false on error. 

msql_select_db() sets the current active database on the server that's associated with the specified 
link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, 
the function will try to establish a link as if msql_connect() was called, and use it. 

Every subsequent call to msql_query() will be made on the active database. 
See also: msql_connect() , msql_pconnect() , and msql_query() . 

Prev Home Next 

msql_result U^ msql_selectdb 



PHP Manual 

Prev Next 



msql_selectdb 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_selectdb ~ select mSQL database 

Description 

See msql_select_db(). 



Prev Home Next 

msql_select_db Up msql_tablename 



PHP Manual 

Prev Next 



msql_tablename 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

msql_tablename ~ get table name of field 

Description 

string msql_tablename(int query _identifier, int field); 

msql_tablename() takes a result pointer returned by the msql_list_tables() function as well as an 
integer index and returns the name of a table. The msql_numrows() function may be used to 
determine the number of tables in the result pointer. 
Example 1. msql_tablename() example 

<?php 

msql_connect ( "localhost " ) ; 

$result = msql_list_tables ( "Wisconsin" ) ; 

$i = 0; 

while ($i < msql_numrows ($result ) ) { 

$tb_names [ $i] = msql_tablename ( $result , $i) ; 

echo $tb_names [$i] . "<BR>"; 

$i++; 
} 
?> 

Prev Home Next 

msql_selectdb Up MySQL functions 



PHP Manual 

Prev Next 



mysq l_af f ected_rows 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_affected_rows ~ Get number of affected rows in previous MySQL operation 

Description 

int mysql_af f ected_rows(int [Hnk_identifier] ); 

mysql_affected_rows() returns the number of rows affected by the last INSERT, UPDATE or 
DELETE query on the server associated with the specified hnk identifier. If the hnk identifier isn't 
specified, the last opened link is assumed. 

If the last query was a DELETE query with no WHERE clause, all of the records will have been 
deleted from the table but this function will return zero. 

This command is not effective for SELECT statements, only on statements which modify records. 
To retrieve the number of rows returned from a SELECT, use mysql_num_rows() . 

Prev Home Next 

MySQL functions U^ mysql_change_user 



PHP Manual 

Prev Next 



mysql_change_user 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_change_user — Change logged in user on active connection 

Description 

int mysql_change_user(string user, string password, string [database] , int [Hnk_identifier] 

); 

mysql_change_user() changes the logged in user on the current active connection, or, if specified 
on the connection given by the link identifier. If a database is specified, this will default or current 
database after the user has been changed. If the new user/password combination fails to be 
authorized the current connected user stays active. 

Note that this function was introduced in PHP 3.0.13 and requires MySQL 3.23.3 or higher. 

Prev Home Next 

mysql_affected_rows Up mysql_close 



PHP Manual 

Prev Next 



mysql_close 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_close ~ close MySQL connection 

Description 

int mysql_close(int [Hnk_identifier] ); 

Returns: true on success, false on error 

mysql_close() closes the link to a MySQL database that's associated with the specified link 
identifier. If the link identifier isn't specified, the last opened link is assumed. 

Note that this isn't usually necessary, as non-persistent open links are automatically closed at the 
end of the script's execution. 

mysql_close() will not close persistent links generated by mysql_pconnect() . 
See also: mysql_connect() , and mysql_pconnect() . 

Prev Home Next 

mysql_change_user lj£ mysql_connect 



PHP Manual 

Prev Next 



mysql_connect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_connect ~ Open a connection to a MySQL Server 

Description 



int mysql_connect(string [hostname [:port] [:/path/to/socket] ] , string [username] , string 
[password] ); 

Returns: A positive MySQL Hnk identifier on success, or false on error. 

mysql_connect() estabhshes a connection to a MySQL server. All of the arguments are optional, 
and if they're missing, defaults are assumed ('localhost', user name of the user that owns the server 
process, empty password). 

The hostname string can also include a port number, eg. "hostname:port" or a path to a socket eg. 
" :/path/to/socket" for the localhost. 

Note: Support for ":port" wass added in 3.0B4. 

Support for the " :/path/to/socket" was added in 3.0.10. 

In case a second call is made to mysql_connect() with the same arguments, no new link will be 
established, but instead, the link identifier of the already opened link will be returned. 

The link to the server will be closed as soon as the execution of the script ends, unless it's closed 
earlier by explicitly calling mysql_close() . 

See also mysql_pconnect() , and mysql_close() . 

Prev Home Next 

mysql_close Ug mysql_create_db 



PHP Manual 

Prev Next 



mysql_create_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_create_db ~ Create a MySQL database 

Description 

int mysql_create_db(string database name, int [Hnk_identifier] ); 

mysql_create_db() attempts to create a new database on the server associated with the specified 
Hnk identifier. 

See also: mysql_drop_db() . For downwards compatibiHty mysql_createdb() can also be used. 

Prev Home Next 

mysql_connect Ug mysql_data_seek 



PHP Manual 

Prev Next 



mysq l_data_seek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_data_seek ~ Move internal result pointer 

Description 

int mysql_data_seek(int result_identifier, int row_number); 

Returns: true on success, false on failure 

mysql_data_seek() moves the internal row pointer of the MySQL result associated with the 
specified result identifier to point to the specified row number. The next call to mysql_fetch_row() 
would return that row. 

Row_number starts at 0. 

Prev Home Next 

mysql_create_db U^ mysql_db_query 



PHP Manual 

Prev Next 



mysql_db_query 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_db_query ~ Send an MySQL query to MySQL 

Description 

int mysql_db_query(string database, string query, int [Hnk_identifier] ); 

Returns: A positive MySQL result identifier to the query result, or false on error. 

mysql_db_query() selects a database and executes a query on it. If the optional link identifier isn't 
specified, the function will try to find an open link to the MySQL server and if no such link is 
found it'll try to create one as if mysql_connect() was called with no arguments 

See also mysql_connect() . For downwards compatibility mysqlQ can also be used. 

Prev Home Next 

mysql_data_seek Up mysql_drop_db 



PHP Manual 

Prev Next 



mysql_drop_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_drop_db ~ Drop (delete) a MySQL database 

Description 

int mysql_drop_db(string database_name, int [Hnk_identifier] ); 

Returns: true on success, false on failure. 

mysql_drop_db() attempts to drop (remove) an entire database from the server associated with the 
specified link identifier. 

See also: mysql_create_db() . For downward compatibility mysql_dropdb() can also be used. 

Prev Home Next 

mysql_db_query Up mysql_errno 



PHP Manual 

Prev Next 



mysql_errno 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mysql_errno ~ Returns the number of the error message from previous MySQL operation 

Description 

int mysql_errno(int [Hnk_identifier] ); 

Errors coming back from the mySQL database backend no longer issue warnings. Instead, use these 
functions to retrieve the error number. 

<?php 

mysql_connect ( "marliesle" ) ; 

echo mysql_errno ( ) .": " .mysql_error ( ) ."<BR>"; 

mysql_select_db ( "nonexistentdb" ) ; 

echo mysql_errno ( ) .": " .mysql_error ( ) ."<BR>"; 

$conn = mysql_query ("SELECT * FROM nonexistenttable" ) ; 

echo mysql_errno ( ) .": " .mysql_error ( ) ."<BR>"; 

?> 

See also: mysql_error() 

Prev Home Next 

mysql_drop_db Ug mysql_error 



PHP Manual 

Prev Next 



mysql_error 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mysql_error ~ Returns the text of the error message from previous MySQL operation 

Description 

string mysql_error(int [Hnk_identifier] ); 

Errors coming back from the mySQL database backend no longer issue warnings. Instead, use these 
functions to retrieve the error string. 

<?php 

mysql_connect ( "marliesle" ) ; 

echo mysql_errno ( ) .": " .mysql_error ( ) ."<BR>"; 

mysql_select_db ( "nonexistentdb" ) ; 

echo mysql_errno ( ) .": " .mysql_error ( ) ."<BR>"; 

$conn = mysql_query ("SELECT * FROM nonexistenttable" ) ; 

echo mysql_errno ( ) .": " .mysql_error ( ) ."<BR>"; 

?> 

See also: mysql_errno() 

Prev Home Next 

mysql_errno Ug mysql_fetch_array 



PHP Manual 

Prev Next 



mysql_fetch_array 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_fetch_array ~ Fetch a result row as an associative array 

Description 

array mysql_fetch_array(int result, int [result_type] ); 

Returns an array that corresponds to the fetched row, or false if there are no more rows. 

mysql_fetch_array() is an extended version of mysql_fetch_row() . In addition to storing the data 
in the numeric indices of the result array, it also stores the data in associative indices, using the field 
names as keys. 

If two or more columns of the result have the same field names, the last column will take 
precedence. To access the other column(s) of the same name, you must the numeric index of the 
column or make an alias for the column. 

select tl.fl as foo t2.fl as bar from tl, t2 

An important thing to note is that using mysql_fetch_array() is NOT significantly slower than 
using mysql_fetch_row() , while it provides a significant added value. 

The optional second argument result_type in mysql_fetch_array() is a constant and can take 
the following values: MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. (This feature was 
added in PHP 3.0.7) 

For further details, also see mysql_fetch_row() 



Example 1. mysql fetch array 

<?php 

mysql_connect ($host, $user, $password) ; 

$result = mysql_db_query ( "database" , "select * from table"); 

while ($row = mysql_f etch_array ( $result ) ) { 

echo $row [ "user_id" ] ; 

echo $row [ "f ullname" ] ; 

} 

mysql_f ree_result ($result) ; 

?> 

Prev Home Next 

mysql_error Ug mysql_fetch_field 



PHP Manual 

Prev Next 



mysql_fetch_field 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mysql_fetch_field ~ Get column information from a result and return as an object 

Description 

object mysql_fetch_field(int result, int [field_offset] ); 

Returns an object containing field information. 

mysql_fetch_field() can be used in order to obtain information about fields in a certain query 
result. If the field offset isn't specified, the next field that wasn't yet retrieved by 
mysql_fetch_field() is retrieved. 

The properties of the object are: 

q name - column name 

q table - name of the table the column belongs to 

q max_length - maximum length of the column 

q not_null - 1 if the column cannot be null 

q primary _key - 1 if the column is a primary key 

q unique_key - 1 if the column is a unique key 

q multiple_key - 1 if the column is a non-unique key 

q numeric - 1 if the column is numeric 

q blob - 1 if the column is a BLOB 

q type - the type of the column 

q unsigned - 1 if the column is unsigned 

q zerofill - 1 if the column is zero-filled 
See also mysql_field_seek() 



Prev Home Next 

mysql_fetch_array Ug mysql_fetch_lengths 



PHP Manual 

Prev Next 



mysql_fetch_lengths 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_fetch_lengths ~ Get the length of each output in a result 

Description 

array mysql_f etch_lengths(int result); 

Returns: An array that corresponds to the lengths of each field in the last row fetched by 
mysql_fetch_row() , or false on error. 

mysql_fetch_lengths() stores the lengths of each result column in the last row returned by 
mysql_fetch_row() , mysql_fetch_array() , and mysql_fetch_object() in an array, starting at offset 
0. 

See also: mysql_fetch_row() . 

Prev Home Next 

mysql_fetch_field Up mysql_fetch_object 



PHP Manual 

Prev Next 



mysql_fetch_obiect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_fetch_object ~ Fetch a result row as an object 

Description 

object mysql_fetch_object(int result, int [result_typ]); 

Returns an object with properties that correspond to the fetched row, or false if there are no more 
rows. 

mysql_fetch_object() is similar to mysql_fetch_array() , with one difference - an object is 
returned, instead of an array. Indirectly, that means that you can only access the data by the field 
names, and not by their offsets (numbers are illegal property names). 

The optional argument result_typ is a constant and can take the following values: 
MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH. 

Speed-wise, the function is identical to mysql_fetch_array() , and almost as quick as 
mysql_fetch_row() (the difference is insignificant). 

Example 1. mysql fetch object 

<?php 

mysql_connect ($host, $user, $password) ; 

$result = mysql_db_query ( "database" , "select * from table"); 

while ($row = mysql_f etch_ob ject ( $result ) ) { 

echo $row->user_id; 

echo $row->f ullname; 

} 

mysql_f ree_result ($result) ; 

?> 

See also: mysql_fetch_array() and mysql_fetch_row() . 

Prev Home Next 

mysql_fetch_lengths Up mysql_fetch_row 



PHP Manual 

Prev Next 



mysq l_f etch_row 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_fetch_row ~ Get a result row as an enumerated array 

Description 

array mysql_f etch_row(int result); 

Returns: An array that corresponds to the fetched row, or false if there are no more rows. 

mysql_fetch_row() fetches one row of data from the result associated with the specified result 
identifier. The row is returned as an array. Each result column is stored in an array offset, starting at 
offset 0. 

Subsequent call to mysql_fetch_row() would return the next row in the result set, or false if there 
are no more rows. 

See also: mysql_fetch_array() , mysql_fetch_object() , mysql_data_seek() , 
mysql_fetch_lengths() , and mysql_result() . 

Prev Home Next 

mysql_fetch_object Up mysql_field_name 



PHP Manual 

Prev Next 



mysql_field_name 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_field_name ~ Get the name of the specified field in a result 

Description 

string mysql_f ield_name(int result, int field_index); 

mysql_field_name() returns the name of the specified field. Arguments to the function is the result 
identifier and the field index, ie. mysql_f ield_name ($result,2); 

Will return the name of the second field in the result associated with the result identifier. 

For downwards compatibility mysql_fieldname() can also be used. 

Prev Home Next 

mysql_fetch_row Up mysql_field_seek 



PHP Manual 

Prev Next 



mysql_field_seek 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_field_seek — Set result pointer to a specified field offset 

Description 

int mysql_f ield_seek(int result, int field_offset); 

Seeks to the specified field offset. If the next call to mysql_fetch_field() won't include a field 
offset, this field would be returned. 

See also: mysql_fetch_field() . 

Prev Home Next 

mysql_field_name U^ mysql_field_table 



PHP Manual 

Prev Next 



mysql_field_table 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_field_table ~ Get name of the table the specified field is in 

Description 

string mysql_f ield_t able (int result, int field_offset); 

Get the table name for field. For downward compatibility mysql_fieldtable() can also be used. 

Prev Home Next 

mysql_field_seek Up mysql_field_type 



PHP Manual 



Prev 



Next 



mysql_field_type 



f 



is function is not supported in the 
P Lite edition, 
ssible workara 



J 



mysql_field_type — Get the type of the specified field in a result 

Description 

string mysql_f ield_type(int result, int field_offset); 

mysql_field_type() is similar to the mysql_field_name() function. The arguments are identical, but the field type is 
returned. This will be one of "int", "real", "string", "blob", or others as detailed in the MySQL documentation. 
Example 1. mysql field types 

<?php 

mysql_connect ( "localhost : 330 6" ) ; 

mysql_select_db ( "Wisconsin" ) ; 

$result = mysql_query ("SELECT * FROM onek"); 

$fields = mysql_num_f ields ( $result ) ; 



$rows = mysql_num_rows ($result ) ; 

$i = 0; 

$table = mysql_f ield_table ($result , 

echo "Your ' " . $table . " ' table has " 

echo "The table has the following fields <BR>"; 

while ($i < $fields) { 

$type = mysql_f ield_type ($result, $i) 
$name = mysql_f ield_name ($result, $i) 
$len = mysql_f ield_len ($result, $i) 
$flags = mysql_f ield_f lags ($result, $i) 



$i); 

$f ields." fields and ".$rows." records <BR>"; 



$name." ".$len." " . $f lags . "<BR>" ; 



echo $type 

$i + + ; 
} 

mysql_close ( ) ; 
?> 



For downward compatibility mysql_fieldtype() can also be used. 



Prev 
mysql_field_table 



Home 
Up 



Next 
mysql_field_flags 



PHP Manual 

Prev Next 



mysql_field_flags 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mysql_field_flags ~ Get the flags associated with the specified field in a result 

Description 

string mysql_field_f lags (int result, int field_offset); 

mysql_field_flags() returns the field flags of the specified field. The flags are reported as a single 
word per flag separated by a single space, so that you can split the returned value using explodeQ . 

The following flags are reported, if your version of MySQL is current enough to support them: 
"not_nuH", "primary_key", "unique_key", "multiple_key", "blob", "unsigned", "zerofill", "binary", 
"enum", "auto_increment", "timestamp". 



For downward compatibility mysql_fieldflags() can also be used. 



Prev Home Next 

mysql_field_type Ug mysql_field_len 



PHP Manual 

Prev Next 



mysql_field_len 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_field_len ~ Returns the length of the specified field 

Description 

int mysql_f ield_len(int result, int field_offset); 

mysql_field_len() returns the length of the specified field. For downward compatibility 
mysql_fieldlen() can also be used. 

Prev Home Next 

mysql_field_flags Up mysql_free_result 



PHP Manual 

Prev Next 



mysq l_f ree_resu It 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_free_result ~ Free result memory 

Description 

int mysql_f ree_result(int result); 

mysql_free_result() only needs to be called if you are worried about using too much memory 
while your script is running. All associated result memory for the specified result identifier will 
automatically be freed. 

For downward compatibility mysql_freeresult() can also be used. 

Prev Home Next 

mysql_field_len Up mysql_insert_id 



PHP Manual 

Prev Next 



mysqijnsertjd 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_insert_id ~ Get the id generated from the previous INSERT operation 

Description 

int mysql_insert_id(int [Hnk_identifier] ); 

mysql_insert_id() returns the ID generated for an AUTO_INCREMENTED field. It will return the 
auto-generated ID returned by the last INSERT query performed using the given 
link_ident if ier. If link_identifier isn't specified, the last opened link is assumed. 

Prev Home Next 

mysql_free_result Up mysql_list_fields 



PHP Manual 

Prev Next 



mysql_list_fields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_Hst_fields ~ List MySQL result fields 

Description 



i n t my s ql_l i s t_f i e 1 ds (string database_name, string table_name, int [link_identifier] ); 

mysql_list_fields() retrieves information about the given tablename. Arguments are the database 
name and the table name. A result pointer is returned which can be used with mysql_field_flags() , 
mysql_field_len() , mysql_field_name() , and mysql_field_type() . 

A result identifier is a positive integer. The function returns -1 if a error occurs. A string describing 
the error will be placed in $phperrmsg, and unless the function was called as @mysql ( ) then 
this error string will also be printed out. 

For downward compatibility mysql_listfields() can also be used. 

Prev Home Next 

mysql_insert_id Up mysql_list_dbs 



PHP Manual 

Prev Next 



mysql_list_dbs 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_Hst_dbs ~ List databases available on on MySQL server 

Description 

int mysql_list_dbs(int [link_identifier] ); 

mysql_list_dbs() will return a result pointer containing the databases available from the current 
mysql daemon. Use the mysql_tablename() function to traverse this result pointer. 

For downward compatibility mysql_listdbs() can also be used. 

Prev Home Next 

mysql_list_fields Ug mysql_list_tables 



PHP Manual 

Prev Next 



mysql_list_tables 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_Hst_tables ~ List tables in a MySQL database 

Description 

i n t my s ql_l i s t_t ab 1 e s (string database, int [Hnk_identifier] ); 

mysql_list_tables() takes a database name and returns a result pointer much like the 
mysql_db_query() function. The mysql_tablename() function should be used to extract the actual 
table names from the result pointer. 

For downward compatibility mysql_listtables() can also be used. 

Prev Home Next 

mysql_list_dbs Up mysql_num_fields 



PHP Manual 

Prev Next 



mysql_num_fields 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_num_fields ~ Get number of fields in result 

Description 



int mysql_num_fields(int result); 

mysql_num_fields() returns the number of fields in a result set. 

See also: mysql_db_query () , mysql_query() , mysql_fetch_field() , mysql_num_rows() . 

For downward compatibility mysql_numfields() can also be used. 

Prev Home Next 

mysql_list_tables Up mysql_num_rows 



PHP Manual 

Prev Next 



my sq l_n u m_ro ws 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_num_rows ~ Get number of rows in result 

Description 

int mysql_num_rows(int result); 

mysql_num_rows() returns the number of rows in a result set. 

See also: mysql_db_query () , mysql_query() and, mysql_f etch_ro w() . 

For downward compatibility mysql_numrows() can also be used. 

Prev Home Next 

mysql_num_fields Up mysql_pconnect 



PHP Manual 

Prev Next 



mysql_pconnect 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysqLpconnect ~ Open a persistent connection to a MySQL Server 

Description 

int mysql_pconnect(string [hostname [:port] [:/path/to/socket] ] , string [username] , string 
[password] ); 

Returns: A positive MySQL persistent Hnk identifier on success, or false on error 

mysql_pconnect() estabhshes a connection to a MySQL server. All of the arguments are optional, 
and if they're missing, defaults are assumed ('localhost', user name of the user that owns the server 
process, empty password). 

The hostname string can also include a port number, eg. "hostname:port" or a path to a socket eg. 
" :/path/to/socket" for the localhost. 

Note: Support for ":port" wass added in 3.0B4. 

Support for the " :/path/to/socket" was added in 3.0.10. 

mysql_pconnect() acts very much like mysql_connect() with two major differences. 

First, when connecting, the function would first try to find a (persistent) link that's already open 
with the same host, username and password. If one is found, an identifier for it will be returned 
instead of opening a new connection. 

Second, the connection to the SQL server will not be closed when the execution of the script ends. 
Instead, the link will remain open for future use ( mysql_dose() will not close links established by 
mysql_pconnect()) . 

This type of links is therefore called 'persistent'. 

Prev Home Next 

mysql_num_rows Up mysql_query 



PHP Manual 

Prev Next 



mysql_query 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysqLquery ~ Send an SQL query to MySQL 

Description 

int mysql_query(string query, int [Hnk_identifier] ); 

mysql_query() sends a query to the currently active database on the server that's associated with 
the specified hnk identifier. If link_identifier isn't specified, the last opened link is 
assumed. If no link is open, the function tries to establish a link as if mysql_connect() was called 
with no arguments, and use it. 

The query string should not end with a semicolon. 

mysql_query() returns TRUE (non-zero) or FALSE to indicate whether or not the query 
succeeded. A return value of TRUE means that the query was legal and could be executed by the 
server. It does not indicate anything about the number of rows affected or returned. It is perfectly 
possible for a query to succeed but affect no rows or return no rows. 

The following query is syntactically invalid, so mysql_query() fails and returns FALSE: 

Example 1. mysql_query() 

<?php 

$result = mysql_query ("SELECT * WHERE 1=1") 

or die ("Invalid query"); 
?> 



The following query is semantically invalid if my_col is not a column in the table my_tbl, so 
mysql_query() fails and returns FALSE: 

Example 2. mysql_query() 

<?php 

$result = mysql_query ("SELECT my_col FROM my_tbl") 

or die ("Invalid query"); 
?> 



mysql_query() will also fail and return FALSE if you don't have permission to access the table(s) 
referenced by the query. 

Assuming the query succeeds, you can call mysql_affected_rows() to find out how many rows 
were affected (for DELETE, INSERT, REPLACE, or UPDATE statements). For SELECT 
statements, mysql_query() returns a new result identifier that you can pass to mysql_result() . 
When you are done with the result set, you can free the resources associated with it by calling 
mysql_free_result() . 

See also: my sq l_af f ected_ro ws () , my sq l_db_q uery () , mysql_free_result() , mysql_result() , 
mysql_select_db () , and mysql_connect() . 

Prey Home Next 

mysqLpconnect Ug mysql_result 



PHP Manual 

Prev Next 



mysql_result 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



mysql_result ~ Get result data 

Description 

int mysql_result(int result, int row, mixed [field] ); 

mysql_result() returns the contents of one cell from a MySQL result set. The field argument can be 
the field's offset, or the field's name, or the field's table dot field's name (fieldname. tablename). If 
the column name has been aliased ('select foo as bar from...'), use the alias instead of the column 
name. 

When working on large result sets, you should consider using one of the functions that fetch an 
entire row (specified below). As these functions return the contents of multiple cells in one function 
call, they're MUCH quicker than mysql_result(). Also, note that specifying a numeric offset for the 
field argument is much quicker than specifying a fieldname or tablename.fieldname argument. 

Calls mysql_result() should not be mixed with calls to other functions that deal with the result set. 

Recommended high-performance alternatives: my sq l_f etch_ro w() , mysql_fetch_array() , and 
mysql_fetch_object() . 

Prev Home Next 

mysqLquery Up mysql_select_db 



PHP Manual 

Prev Next 



mysql_select_db 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

mysql_select_db ~ Select a MySQL database 

Description 

int mysql_select_db(string database_name, int [Hnk_identifier] ); 

Returns: true on success, false on error 

mysql_select_db() sets the current active database on the server that's associated with the specified 
link identifier. If no link identifier is specified, the last opened link is assumed. If no link is open, 
the function will try to establish a link as if mysql_connect() was called, and use it. 

Every subsequent call to mysql_query() will be made on the active database. 

See also: mysql_connect() , mysql_pconnect() , and mysql_query() 

For downward compatibility mysql_selectdb() can also be used. 

Prev Home Next 

mysql_result Up mysql_tablename 



PHP Manual 

Prev Next 

Ora_Bind 

Hnis function is not supported in the^^H 
»1P Lite edition. ^^ 

Possible workarc^iiliiliiliilliliy 

Ora_Bind — bind a PHP variable to an Oracle parameter 

Description 

int ora_bind(int cursor, string PHP variable name, string SQL parameter name, int length, int [type]); 

Returns true if the bind succeeds, otherwise false. Details about the error can be retrieved using the ora_error() and 
ora_errorcode() functions. 

This function binds the named PHP variable with a SQL parameter. The SQL parameter must be in the form ":name". 
With the optional type parameter, you can define whether the SQL parameter is an in/out (0, default), in (1) or out (2) 
parameter. As of PHP 3.0.1, you can use the constants ORA_BIND_INOUT, ORA_BIND_IN and ORA_BIND_OUT 
instead of the numbers. 

ora_bind must be called after ora_parse() and before ora_exec() . Input values can be given by assignment to the bound 
PHP variables, after calling ora_exec() the bound PHP variables contain the output values if available. 

<?php 

ora_parse ($curs, "declare tmp INTEGER; begin tmp := :in; : out := tmp; :x := 7.77; 

end; " ) ; 

ora_bind ($curs, "result", ":x", $len, 2); 

ora_bind ($curs , "input", ":in", 5, 1); 

ora_bind ($curs, "output", ":out", 5, 2); 

$ input = 7 65; 

ora_exec ($curs) ; 

echo "Result: $result<BR>Out : $output<BR>In : $input"; 

?> 

Prev Home Next 

Oracle functions Up Ora_Close 



PHP Manual 

Prev Next 



Ora Close 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Close ~ close an Oracle cursor 

Description 

int ora_close(int cursor); 

Returns true if the close succeeds, otherwise false. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. 

This function closes a data cursor opened with ora_open() . 

Prev Home Next 

Ora_Bind U^ Ora_ColumnName 



PHP Manual 

Prev Next 



Ora_ColumnName 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_ColumnName ~ get name of Oracle result column 

Description 

string Ora_ColumnName(int cursor, int column); 



Returns the name of the field/column column on the cursor cursor. The returned name is in all 
uppercase letters. 

Prev Home Next 

Ora_Close Up Ora_ColumnType 



PHP Manual 

Prev Next 



Ora_ColumnType 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_ColumnType ~ get type of Oracle result column 

Description 

string Ora_ColumnType(int cursor, int column); 

Returns the Oracle data type name of the field/column col umn on the cursor cursor. The 
returned type will be one of the following: 

"VARCHAR2" 

"VARCHAR" 

"CHAR" 

"NUMBER" 

"LONG" 

"LONG RAW" 

"ROWID" 

"DATE" 

"CURSOR" 

Prev Home Next 

Ora_ColumnName Up Ora_Commit 



PHP Manual 

Prev Next 



Ora_Commit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Commit ~ commit an Oracle transaction 

Description 

int ora_commit(int conn); 

Returns true on success, false on error. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. This function commits an Oracle transaction. A 
transaction is defined as all the changes on a given connection since the last commit/rollback, 
autocommit was turned off or when the connection was established. 

Prev Home Next 

Ora_ColumnType Up Ora_CommitOff 



PHP Manual 

Prev Next 



Ora_CommitOff 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_CommitOff ~ disable automatic commit 

Description 

int ora_commitof f (int conn); 



Returns true on success, false on error. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. 

This function turns off automatic commit after each ora_exec() . 

Prev Home Next 

Ora_Commit U^ Ora_CommitOn 



PHP Manual 

Prev Next 



Ora_CommitOn 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_CommitOn ~ enable automatic commit 

Description 



int ora_commiton(int conn); 

This function turns on automatic commit after each ora_exec() on the given connection. 

Returns true on success, false on error. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. 

Prev Home Next 

Ora_CommitOff U^ Ora_Error 



PHP Manual 

Prev Next 



Ora_Error 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Error ~ get Oracle error message 

Description 

string Ora_Error(int cursor_or_connection); 

Returns an error message of the form XXX- NNNNN where. XXX is where the error comes from and 
NNNNN identifies the error message. 

Note: Support for connection ids was added in 3.0.4. 

On UNIX versions of Oracle, you can find details about an error message like this: $ oerr ora 

00001 00001, 00000, "unique constraint (%s.%s) violated" // 
*Cause: An update or insert statement attempted to insert a 
duplicate key // For Trusted ORACLE configured in DBMS MAC mode, 
you may see // this message if a duplicate entry exists at a 
different level. // *Action: Either remove the unique restriction 
or do not insert the key 

Prev Home Next 

Ora_CommitOn Up Ora_ErrorCode 



PHP Manual 

Prev Next 



Ora ErrorCode 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_ErrorCode ~ get Oracle error code 

Description 



int Ora_ErrorCode(int cursor_or_connection); 

Returns the numeric error code of the last executed statement on the specified cursor or connection. 
Note: Support for connection ids was added in 3.0.4. 

Prev Home Next 

Ora_Error Ug Ora_Exec 



PHP Manual 

Prev Next 



Ora Exec 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Exec ~ execute parsed statement on an Oracle cursor 

Description 



int ora_exec(int cursor); 

Returns true on success, false on error. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. 

Prev Home Next 

Ora_ErrorCode Up Ora_Fetch 



PHP Manual 

Prev Next 



Ora_Fetch 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Fetch — fetch a row of data from a cursor 

Description 

int ora_fetch(int cursor); 

Returns true (a row was fetched) or false (no more rows, or an error occured). If an error occured, 
details can be retrieved using the ora_error() and ora_errorcode() functions. If there was no error, 
ora_errorcode() will return 0. Retrieves a row of data from the specified cursor. 

Prev Home Next 

Ora_Exec Up Ora_GetColumn 



PHP Manual 

Prev Next 



Ora_GetColumn 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_GetColumn ~ get data from a fetched row 

Description 



mixed ora_getcolumn(int cursor, mixed column); 

Returns the column data. If an error occurs, False is returned and ora_errorcode() will return a 
non-zero value. Note, however, that a test for False on the results from this function may be true in 
cases where there is not error as well (NULL result, empty string, the number 0, the string "0"). 
Fetches the data for a column or function result. 

Prev Home Next 

Ora_Fetch Up Ora_Logoff 



PHP Manual 

Prev Next 



Ora_Logoff 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Logoff ~ close an Oracle connection 

Description 

int ora_logoff(int connection); 

Returns true on success, False on error. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. Logs out the user and disconnects from the server. 

Prev Home Next 

Ora_GetColumn Up Ora_Logon 



PHP Manual 

Prev Next 



Ora_Logon 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Logon ~ open an Oracle connection 

Description 

int ora_logon(string user, string password); 

EstabHshes a connection between PHP and an Oracle database with the given username and 
password. 

Connections can be made using SQL*Net by supplying the TNS name to user like this: 
$conn = Ora_Logon ("user (3 TNSNAME" , "pass"); 

If you have character data with non- ASCII characters, you should make sure that NLS_LANG is set 
in your environment. For server modules, you should set it in the server's environment before 
starting the server. 

Returns a connection index on success, or false on failure. Details about the error can be retrieved 
using the ora_error() and ora_errorcode() functions. 

Prev Home Next 

Ora_Logoff Up Ora_Open 



PHP Manual 

Prev Next 



Ora_Open 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



Ora_Open ~ open an Oracle cursor 

Description 

int ora_open(int connection); 

Opens an Oracle cursor associated with connection. 

Returns a cursor index or False on failure. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. 

Prev Home Next 

Ora_Logon U^ Ora_Parse 



PHP Manual 

Prev Next 



Ora Parse 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Parse ~ parse an SQL statement 

Description 

i n t or a_p arse (int cursor_ind, string sql_statement, int defer) ; 

This function parses an SQL statement or a PL/SQL block and associates it with the given cursor. 
Returns on success or -1 on error. 

Prev Home Next 

Ora_Open Up Ora_Rollback 



PHP Manual 

Prev Next 



Ora_Rollback 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

Ora_Rollback — roll back transaction 

Description 



i n t or a_r o 1 1 b a c k (int connection) ; 

This function undoes an Oracle transaction. (See ora_commit() for the definition of a transaction.) 

Returns true on success, false on error. Details about the error can be retrieved using the 
ora_error() and ora_errorcode() functions. 

Prev Home Next 

Ora_Parse U^ Oracle 8 functions 



PHP Manual 

Prev Next 



OCIDefineByName 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



OCIDefineByName ~ Use a PHP variable for the define-step during a SELECT 

Description 

int OCIDef ineByName(int stmt, string Column-Name, mixed &variable, int [type]); 

OCIDefineByNameQ uses fetches SQL-Columns into user-defined PHP- Variables. Be careful that 
Oracle user ALL-UPPERCASE column-names, whereby in your select you can also write 
lower-case. OCIDefineByNameQ expects the Column-Name to be in uppercase. If you define a 
variable that doesn't exists in you select statement, no error will be given! 

If you need to define an abstract Datatype (LOB/ROWID/BFILE) you need to allocate it first using 
O CINe wDescriptor function. See also the OCIBindByNameQ function. 

Example 1. OCIDefineByName 

<?php 

/* OCIDefineByPos example thies@digicol.de (980219) */ 

$conn = OCILogon ( "scott" , "tiger" ) ; 

$stmt = OCIParse ($conn, "select empno, ename from emp"); 

/* the define MUST be done BEFORE ociexecute ! */ 

OCIDefineByName ($stmt, "EMPNO", &$empno) ; 
OCIDefineByName ($stmt, "ENAME", &$ename) ; 

OCIExecute ($stmt) ; 

while (OCIFetch($stmt) ) { 

echo "empno :". $empno ." \n" ; 

echo "ename :". $ename ." \n" ; 
} 



OCIFreeStatement ($stmt) ; 

OCILogof f ($conn) ; 

?> 



Prev Home Next 

Oracle 8 functions U^ OCIBindByName 



PHP Manual 

Prev Next 



OCIBindByName 



i 




his function is no« 

HP Lite edition. 

ossible workaround not yet published. 



OCIBindByName — Bind a PHP variable to an Oracle Placeholder 

Description 

int OCIBindByName(int stmt, string ph_name, mixed &variable, intlength, int [type]); 

OCIBindByNameQ binds the PHP variable variable to the Oracle placeholder ph_name. Whether it will be 
used for input or output will be determined run-time, and the necessary storage space will be allocated. The 
length paramter sets the maximum length for the bind. If you set length to -1 OCIBindByNameQ will use 
the current length of variable to set the maximum length. 

If you need to bind an abstract Datatype (LOB/ROWID/BFILE) you need to allocate it first using 
OCINewDescriptorQ function. The length is not used for abstract Datatypes and should be set to -1. The 
type variable tells oracle, what kind of descriptor we want to use. Possible values are: OCI_B_FILE 
(Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) 
and OCI_B_ROWID (ROWID). 

Example 1. OCIDefineByName 

<?php 

/* OCIBindByPos example thies@digicol.de (980221) 

inserts 3 resords into emp, and uses the ROWID for updating the 
records just after the insert . 

$conn = OCILogon ( "scott" , "tiger" ) ; 

$stmt = OCIParse ( $conn, "insert into emp (empno, ename) ". 

"values (:empno, rename) ". 
"returning ROWID into :rid"); 

$data = array (1111 => "Larry", 2222 => "Bill", 3333 => "Jim"); 

$rowid = OCINewDescriptor ($conn, OCI_D_ROWID) ; 

OCIBindByName ( $stmt , " : empno" , & $empno, 32 ) ; 
OCIBindByName ( $stmt , " : ename" , &$ ename, 32 ) ; 
OCIBindByName ($stmt, " :rid", &$rowid, -1, OCI_B_ROWID) ; 

$update = OCIParse ( $conn, "update emp set sal = :sal where ROWID = :rid"); 
OCIBindByName ($update, " :rid", &$rowid, -1, OCI_B_ROWID) ; 



OCIBindByName ($update, ":sal",&$sal,32); 

$sal = 10000; 

while (list ( $empno, $ename) = each ( $data) ) { 
OCIExecute ($stmt) ; 
OCIExecute ($update) ; 

} 

$rowid->f ree ( ) ; 

OCIFreeStatement ($update) ; 
OCIFreeStatement ($stmt) ; 

$stmt = OCIParse ( $conn, "select * from emp where empno in (1111,2222,3333)"); 
OCIExecute ($stmt) ; 

while (OCIFetchlnto ($stmt, &$arr,OCI_ASSOC) ) { 
var_dump ( $arr ) ; 

} 

OCIFreeStatement ($stmt) ; 

/* delete our "junk" from the emp table. ... */ 

$stmt = OCIParse ( $conn, "delete from emp where empno in (1111,2222,3333)"); 

OCIExecute ($stmt) ; 

OCIFreeStatement ($stmt) ; 

OCILogof f ($conn) ; 
?> 

Prev Home Next 

OCIDefineByName Ue OCILogon 



PHP Manual 

Prev Next 



OCILogon 




OCILogon — Establishes a connection to Oracle 

Description 

int OCILogon(string username, string password, string [db]); 

OCILogonQ returns an connection identifier needed for most other OCI calls. The optional third parameter 
can either contain the name of the local Oracle instance or the name of the entry in tnsnames.ora to which you 
want to connect. If the optional third parameter is not specified, PHP uses the environment variables 
ORACLE_SID (Oracle instance) or TWO_TASK (tnsnames.ora) to determine which database to connect to. 

Connections are shared at the page level when using OCILogonQ . This means that commits and rollbacks 
apply to all open transactions in the page, even if you have created multiple connections. 

This example demonstrates how the connections are shared. 

Example 1. OCILogon 

<?php 

print "<HTML><PRE>"; 
$db = 



II II . 



$cl = ocilogon (" scott ", "tiger ", $db) ; 
$c2 = ocilogon (" scott ", "tiger ", $db) ; 

function create_table ( $conn) 

{ $stmt = ociparse ($conn, "create table scott. hallo (test 

varchar2 (64) ) ") ; 

ociexecute ($stmt) ; 

echo $conn." created table\n\n"; 
} 

function drop_table ( $conn) 

{ $stmt = ociparse ($conn, "drop table scott . hallo" ) ; 

ociexecute ($stmt) ; 

echo $conn." dropped table\n\n"; 
} 

function insert_data ( $conn) 

{ $stmt = ociparse ($conn, "insert into scott. hallo values (' $conn ' 

to_char (sysdate, 'DD-MON-YY HH24 :MI : SS ' ) ) ") ; 



ociexecute ($stmt, OCI_DEFAULT) ; 
echo $conn." inserted hallo\n\n"; 



} 



function delete_data ( $conn) 

{ $stmt = ociparse ($conn, "delete from scott . hallo" ) ; 

ociexecute ($stmt, OCI_DEFAULT) ; 

echo $conn." deleted hallo\n\n"; 
} 

function commit ( $conn) 
{ ocicommit ( $conn) ; 

echo $conn." commited\n\n" ; 
} 



function rollback ( $conn) 
{ ocirollback ( $conn) ; 

echo $conn." rollback\n\n" ; 
} 

function select_data ( $conn) 

{ $stmt = ociparse ($conn, "select 

ociexecute ($stmt, OCI_DEFAULT) ; 

echo $conn. " selecting\n\n" ; 

while (ocif etch ( $stmt ) ) 

echo $conn." <" . ociresult ( $stmt , "TEST" ) . ">\n\n" ; 

echo $conn." done\n\n"; 

} 



from scott . hallo" ) ; 



create_table ($cl) ; 
insert_data ($cl) ; 
insert_data ($c2) ; 



// Insert a row using cl 
// Insert a row using c2 



select_data ($cl) ; 
select_data ($c2) ; 



// Results of both inserts are returned 



rollback ( $cl ) ; 



// Rollback using cl 



select_data ($cl) ; 
select_data ($c2) ; 



// Both inserts have been rolled back 



insert_data ($c2) ; 
commit ( $c2 ) ; 



// Insert a row using c2 
// commit using c2 



select_data ($cl) ; 



// result of c2 insert is returned 



delete_data ($cl) 
select_data ($cl) 
select_data ($c2) 
commit ( $cl ) ; 



// delete all rows in table using cl 

// no rows returned 

// no rows returned 

// commit using cl 



select_data ($cl) ; 
select_data ($c2) ; 



// no rows returned 
// no rows returned 



drop_table ( $cl ) ; 
print "</PRE></HTML>"; 
?> 

See also OCIPLogonQ and OCINLogonQ. 



Prey Home Next 

OCIBindByName Ug OCIPLogon 



PHP Manual 

Prev Next 



OCIPLogon 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



OCIPLogon — Connect to an Oracle database and log on using a persistant connection. Returns a 
new session. 



Description 



int OCIPLogon(string username, string password, string [db]); 

GCIPLogonQ creates a persistent connection to an Oracle 8 database and logs on. The optional 
third parameter can either contain the name of the local Oracle instance or the name of the entry in 
tnsnames.ora to which you want to connect. If the optional third parameter is not specified, PHP 
uses the environment variables ORACLE_SID (Oracle instance) or TWO_TASK (tnsnames.ora) to 
determine which database to connect to. 

See also GCILogonQ and GCINLogonQ . 

Prev Home Next 

OCILogon Up OCINLogon 



PHP Manual 

Prev Next 



OCINLogon 




OCINLogon — Connect to an Oracle database and log on using a new connection. Returns a new session. 

Description 

int OCINLogon(string usemame, string password, string [db]); 

OCINLogonQ creates a new connection to an Oracle 8 database and logs on. The optional third parameter can 
either contain the name of the local Oracle instance or the name of the entry in tnsnames.ora to which you 
want to connect. If the optional third parameter is not specified, PHP uses the environment variables 
ORACLE_SID (Oracle instance) or TWO_TASK (tnsnames.ora) to determine which database to connect to. 

OCINLogonQ forces a new connection. This should be used if you need to isolate a set of transactions. By 
default, connections are shared at the page level if using OCILogonQ or at the web server process level if 
using OCIPLogonQ . If you have multiple connections open using OCINLogonQ , all commits and rollbacks 
apply to the specified connection only. 

This example demonstrates how the connections are separated. 

Example 1. OCINLogon 

<?php 

print "<HTML><PRE>"; 

$db = ""; 

$cl = ocilogon ( "scott ", "tiger ", $db) ; 
$c2 = ocinlogon (" scott ", "tiger ", $db) ; 

function create_table ( $conn) 

{ $stmt = ociparse ($conn, "create table scott. hallo (test 

varchar2 (64) ) ") ; 

ociexecute ($stmt) ; 

echo $conn." created table\n\n"; 
} 

function drop_table ( $conn) 

{ $stmt = ociparse ($conn, "drop table scott . hallo" ) ; 

ociexecute ($stmt) ; 

echo $conn." dropped table\n\n"; 
} 

function insert_data ( $conn) 



{ $stmt = ociparse ($conn, "insert into scott. hallo values (' $conn ' 
to_char (sysdate, 'DD-MON-YY HH24 :MI : SS ' ) ) ") ; 

ociexecute ($stmt, OCI_DEFAULT) ; 

echo $conn." inserted hallo\n\n"; 
} 

function delete_data ( $conn) 

{ $stmt = ociparse ($conn, "delete from scott .hallo" ) ; 

ociexecute ($stmt, OCI_DEFAULT) ; 

echo $conn." deleted hallo\n\n"; 
} 

function commit ( $conn) 
{ ocicommit ( $conn) ; 

echo $conn." commited\n\n" ; 
} 

function rollback ( $conn) 
{ ocirollback ( $conn) ; 

echo $conn." rollback\n\n" ; 
} 

function select_data ( $conn) 

{ $stmt = ociparse ($conn, " select * from scott . hallo" ) ; 

ociexecute ($stmt, OCI_DEFAULT) ; 

echo $conn. " selecting\n\n" ; 

while (ocif etch ( $stmt ) ) 

echo $conn." <" . ociresult ( $stmt , "TEST" ) . ">\n\n" ; 

echo $conn." done\n\n"; 

} 

create_table ($cl) ; 
insert_data ($cl) ; 

select_data ($cl) ; 
select_data ($c2) ; 

rollback ( $cl ) ; 

select_data ($cl) ; 
select_data ($c2) ; 

insert_data ($c2) ; 
commit ( $c2 ) ; 

select_data ($cl) ; 

delete_data ($cl) ; 
select_data ($cl) ; 
select_data ($c2) ; 
commit ( $cl ) ; 

select_data ($cl) ; 



select_data ($c2) ; 



drop_table ( $cl ) ; 
print "</PRE></HTML>"; 
?> 

See also OCILogonQ and OCIPLogonQ . 

Prev Home Next 

OCIPLogon U2 OCILogOff 



PHP Manual 

Prev Next 



OCILogOff 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

OCILogOff ~ Disconnects from Oracle 

Description 

int OCILogOff(int connection); 
GCILogOffQ closes an Oracle connection. 



Prev Home Next 

OCINLogon Up OCIExecute 



PHP Manual 

Prev Next 



OCI Execute 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

OCIExecute ~ Execute a statement 

Description 

int OCIExecute(int statement, int [mode] ) ; 

OCIExecuteQ executes a previously parsed statement, (see OCIParseQ ). The optional mode 
allows you to specify the execution-mode (default is OCI_COMMIT_ON_SUCCESS). If you don't 
want statements to be commited automaticly specify OCI_DEFAULT as your mode. 

Prev Home Next 

OCILogOff Up OCICommit 



PHP Manual 

Prev Next 



OCICommit 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

OCICommit ~ Commits outstanding transactions 

Description 

int OC I Commit(int connection); 

OCICommitQ commits all outstanding statements for Oracle connection connection. 

Prev Home Next 

OCIExecute Up OCIRollback 



PHP Manual 

Prev Next 



OCIRollback 

■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 

OCIRollback ~ Rolls back outstanding transactions 

Description 

int OC I Ro lib a ck(int connection); 

OCIRollbackQ rolls back all outstanding statements for Oracle connection connection. 

Prev Home Next 

OCICommit Up OCINewDescriptor 



PHP Manual 

Prev Next 



OCINewDescriptor 




^lis function is not si 
PHP Lite edition. 
passible workaround not yet published. 

OCINewDescriptor — Initialize a new empty descriptor LOB/FILE (LOB is default) 

Description 

string OCINewDescriptor(int connection, int [type]); 

OCINewDescriptorQ Allocates storage to hold descriptors or LOB locators. Valid values for the valid type are 
OCI_D_FILE, OCI_D_LOB, OCI_D_ROWID. For LOB desriptors, the methods load, save, and savefile are associated with 
the descriptor, for BFILE only the load method exists. See the second example usage hints. 

Example 1. OCINewDescriptor 

<?php 

/* This script is designed to be called from a HTML form. 

* It expects $user, $password, $table, $where, and $commitsize 

* to be passed in from the form. The script then deletes 

* the selected rows using the ROWID and commits after each 

* set of $commitsize rows. (Use with care, there is no rollback) 
V 

$conn = OCILogon ($user, $password) ; 

$stmt = OCIParse ($conn, "select rowid from $table $where"); 

$rowid = OCINewDescriptor ($conn,OCI_D_ROWID) ; 

OCIDefineByName ($stmt, "ROWID", &$rowid) ; 

OCIExecute ($stmt) ; 

while { OCIFetch($stmt) ) { 

$nrows = OCIRowCount ($stmt ) ; 

$delete = OCIParse ($conn, "delete from $table where ROWID = :rid"); 

OCIBindByName ($delete, " :rid", &$ rowid, -1, OCI_B_ROWID) ; 

OCIExecute ($delete) ; 

print "$nrows\n"; 

if ( ($nrows % $commitsize) == ) { 
OCICommit ($conn) ; 

} 
} 

$nrows = OCIRowCount ($ stmt ) ; 
print "$nrows deleted. .. \n" ; 
OCIFreeStatement ($stmt) ; 
OCILogof f ($conn) ; 
?> 

<?php 

/* This script demonstrates file upload to LOB columns 

* The formfield used for this example looks like this 

* <form action="upload.php3" method="post " enctype="multipart/f orm-data"> 

* <input type="file" name="lob_upload"> 

V 
if ( ! isset ($lob_upload) || $lob_upload == 'none'){ 



?> 

<form action="upload.php3" method="post " enctype="multipart/f orm-data"> 

Upload file: <input type="file" name="lob_upload"><br> 

<input type= "submit" value="Upload"> - <input type="reset "> 

</form> 

<?php 

} else { 

// $lob_upload contains the temporary filename of the uploaded file 
$conn = OCILogon ($user, $password) ; 
$lob = OCINewDescriptor ($conn, OCI_D_LOB) ; 

$stmt = OCIParse ($conn, "insert into $table (id, the_blob) values (my_seq.NEXTVAL, 
EMPTY_BLOB ( ) ) returning the_blob into : the_blob" ) ; 

OCIBindByName ($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB) ; 
OCIExecute ($stmt) ; 
if ($lob->savef ile ($lob_upload) ) { 
OCICommit ($conn) ; 

echo "Blob successfully uploaded\n"; 
} else { 

echo "Couldn't upload Blob\n"; 
} 

OCIFreeDescriptor ($lob) ; 
OCIFreeStatement ($stmt) ; 
OCILogof f ($conn) ; 
} 
?> 



Prev 
OCIRollback 



Home 



Next 
OCIRowCount 



PHP Manual 

Prev Next 



OCIRowCount 

■This function is not supported in tl^^^f 
PHP Lite edition. ^^H 

^^ossible workaround not yet published. J 

OCIRowCount — Gets the number of affected rows 

Description 

int OCIRowCount(int statement); 



OCIRowCountsO returns the number of rows affected for eg update- statements. This funtions will not 
tell you the number of rows that a select will return! 

Example 1. OCIRowCount 

<?php 

print "<HTML><PRE>"; 

$conn = OCILogon ( "scott" , "tiger" ) ; 

$stmt = OCIParse ($conn, "create table emp2 as select * from emp"); 

OCIExecute ($stmt) ; 

print OCIRowCount ( $stmt) . " rows inserted. <BR>" ; 

OCIFreeStatement ($stmt) ; 

$stmt = OCIParse ( $conn, "delete from emp2"); 

OCIExecute ($stmt) ; 

print OCIRowCount ($stmt) . " rows deleted. <BR>" ; 

OCICommit ($conn) ; 

OCIFreeStatement ($stmt) ; 

$stmt = OCIParse ( $conn, "drop table emp2"); 

OCIExecute ($stmt) ; 

OCIFreeStatement ($stmt) ; 

OCILogOff ($conn) ; 

print "</PRE></HTML>"; 
?> 

Prev Home Next 

OCINewDescriptor Up OCINumCols 



PHP Manual 

Prev Next 



OCINumCols 



■This function is not supported in the ^^M 
IpHP Lite edition. ^ 

IPossible workaround not yet pubUsh^^B 



OCINumCols ~ Return the number of result columns in a statement 

Description 

int OCINumCols(int stmt); 

OCINumColsQ returns the number of columns in a statement 
Example 1. OCINumCols 

<?php 

print "<HTML><PRE>\n"; 
$conn = OCILogon ( "scott " , "tiger"); 
$stmt = OCIParse ($conn, "select * from emp"); 
OCIExecute ($stmt) ; 
while ( OCIFetch($stmt) ) {